本文整理汇总了PHP中CodeCoverageManager类的典型用法代码示例。如果您正苦于以下问题:PHP CodeCoverageManager类的具体用法?PHP CodeCoverageManager怎么用?PHP CodeCoverageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeCoverageManager类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __run
/**
* Executes the tests depending on our settings
*
* @return void
* @access private
*/
public function __run()
{
$Reporter = new CakeXmlReporter('utf-8', array('app' => $this->Manager->appTest, 'plugin' => $this->Manager->pluginTest, 'group' => $this->type === 'group', 'codeCoverage' => $this->doCoverage));
if ($this->doCoverage) {
if (!extension_loaded('xdebug')) {
$this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true));
$this->_stop(0);
}
}
ob_start();
try {
if ($this->type == 'all') {
$result = $this->Manager->runAllTests($Reporter);
} else {
if ($this->type == 'group') {
$ucFirstGroup = ucfirst($this->file);
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::init($ucFirstGroup, $Reporter);
CodeCoverageManager::start();
}
$result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
} else {
$folder = $folder = $this->__findFolderByCategory($this->category);
$case = $this->__getFileName($folder, $this->isPluginTest);
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::init($case, $Reporter);
CodeCoverageManager::start();
}
$result = $this->Manager->runTestCase($case, $Reporter);
}
}
} catch (Exception $e) {
ob_get_clean();
$this->out('Tests failed to run. ' . $e->getMessage());
$this->_stop(1);
}
$xml = ob_get_clean();
$xmlD = new DOMDocument();
$xmlD->loadXML($xml);
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load(dirname(__FILE__) . DS . 'xsl' . DS . 'to-junit.xsl');
$xslt->importStylesheet($XSL);
$out = $xslt->transformToXML($xmlD);
$time = time();
file_put_contents(ROOT . DS . "build" . DS . "logs" . DS . "junit-{$time}.xml", $out);
echo "Done.\n";
}
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:56,代码来源:testreport.php
示例2: paintFooter
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param string $test_name Name class of test.
* @return void
* @access public
*/
function paintFooter($test_name)
{
if ($this->getFailCount() + $this->getExceptionCount() == 0) {
echo "OK\n";
} else {
echo "FAILURES!!!\n";
}
echo "Test cases run: " . $this->getTestCaseProgress() . "/" . $this->getTestCaseCount() . ", Passes: " . $this->getPassCount() . ", Failures: " . $this->getFailCount() . ", Exceptions: " . $this->getExceptionCount() . "\n";
echo 'Time taken by tests (in seconds): ' . $this->_timeDuration . "\n";
if (function_exists('memory_get_peak_usage')) {
echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n";
}
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage'] && class_exists('CodeCoverageManager')) {
CodeCoverageManager::report();
}
}
开发者ID:cls1991,项目名称:ryzomcore,代码行数:24,代码来源:cake_text_reporter.php
示例3: testCalculateCodeCoverage
/**
* testCalculateCodeCoverage method
*
* @access public
* @return void
*/
function testCalculateCodeCoverage()
{
$manager =& CodeCoverageManager::getInstance();
$data = array('25' => array(100, 25), '50' => array(100, 50), '0' => array(0, 0), '0' => array(100, 0), '100' => array(100, 100));
foreach ($data as $coverage => $lines) {
$this->assertEqual($coverage, $manager->__calcCoverage($lines[0], $lines[1]));
}
$manager->__calcCoverage(100, 1000);
$this->assertError();
}
开发者ID:acerato,项目名称:cntcetp,代码行数:16,代码来源:code_coverage_manager.test.php
示例4: paintFooter
/**
* Paints the end of the test with a summary of
* the passes and failures.
*
* @param string $test_name Name class of test.
* @return void
* @access public
*/
function paintFooter($test_name)
{
$colour = $this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green";
echo "</ul>\n";
echo "<div style=\"";
echo "padding: 8px; margin: 1em 0; background-color: {$colour}; color: white;";
echo "\">";
echo $this->getTestCaseProgress() . "/" . $this->getTestCaseCount();
echo " test cases complete:\n";
echo "<strong>" . $this->getPassCount() . "</strong> passes, ";
echo "<strong>" . $this->getFailCount() . "</strong> fails and ";
echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions.";
echo "</div>\n";
echo '<div style="padding:0 0 5px;">';
echo '<p><strong>Time taken by tests (in seconds):</strong> ' . $this->_timeDuration . '</p>';
if (function_exists('memory_get_peak_usage')) {
echo '<p><strong>Peak memory use: (in bytes):</strong> ' . number_format(memory_get_peak_usage()) . '</p>';
}
echo $this->_paintLinks();
echo '</div>';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage'] && class_exists('CodeCoverageManager')) {
CodeCoverageManager::report();
}
$this->paintDocumentEnd();
}
开发者ID:asairoha,项目名称:pj01,代码行数:33,代码来源:cake_html_reporter.php
示例5: paintFooter
/**
* Paint a footer with test case name, timestamp, counts of fails and exceptions.
*/
function paintFooter($test_name)
{
$buffer = $this->getTestCaseProgress() . '/' . $this->getTestCaseCount() . ' test cases complete: ';
if (0 < $this->getFailCount() + $this->getExceptionCount()) {
$buffer .= $this->getPassCount() . " passes";
if (0 < $this->getFailCount()) {
$buffer .= ", " . $this->getFailCount() . " fails";
}
if (0 < $this->getExceptionCount()) {
$buffer .= ", " . $this->getExceptionCount() . " exceptions";
}
$buffer .= ".\n";
$buffer .= $this->_timeStats();
fwrite(STDOUT, $buffer);
} else {
fwrite(STDOUT, $buffer . $this->getPassCount() . " passes.\n" . $this->_timeStats());
}
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage'] && class_exists('CodeCoverageManager')) {
CodeCoverageManager::report();
}
}
开发者ID:geethuann,项目名称:assignment3,代码行数:24,代码来源:cake_cli_reporter.php
示例6: CakeTestsGetReporter
if ('all' == $_GET['group']) {
TestManager::runAllTests(CakeTestsGetReporter());
} else {
if ($analyzeCodeCoverage) {
CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
}
TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
if ($analyzeCodeCoverage) {
CodeCoverageManager::report();
}
}
CakePHPTestRunMore();
CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['case'])) {
if ($analyzeCodeCoverage) {
CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
}
TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
if ($analyzeCodeCoverage) {
CodeCoverageManager::report();
}
CakePHPTestRunMore();
CakePHPTestAnalyzeCodeCoverage();
} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
CakePHPTestCaseList();
} else {
CakePHPTestGroupTestList();
}
CakePHPTestSuiteFooter();
$output = ob_get_clean();
echo $output;
开发者ID:laiello,项目名称:myopensources,代码行数:31,代码来源:test.php
示例7: _runTestCase
/**
* Runs a test case file.
*
* @return void
*/
function _runTestCase()
{
$Reporter =& CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['case'], $Reporter);
}
$this->Manager->runTestCase($this->params['case'], $Reporter);
}
开发者ID:sathishkumarb,项目名称:HVMS,代码行数:13,代码来源:cake_test_suite_dispatcher.php
示例8: __getTestFilesPath
/**
* Gets us the base path to look for the test files
*
* @param string $isApp
* @return void
* @access public
*/
function __getTestFilesPath($isApp = true)
{
$manager = CodeCoverageManager::getInstance();
$path = ROOT . DS;
if ($isApp) {
$path .= APP_DIR . DS;
} elseif (!!$manager->pluginTest) {
$pluginPath = APP . 'plugins' . DS . $manager->pluginTest . DS;
$pluginPaths = Configure::read('pluginPaths');
foreach ($pluginPaths as $tmpPath) {
$tmpPath = $tmpPath . $manager->pluginTest . DS;
if (file_exists($tmpPath)) {
$pluginPath = $tmpPath;
break;
}
}
$path = $pluginPath;
} else {
$path = TEST_CAKE_CORE_INCLUDE_PATH;
}
return $path;
}
开发者ID:BGCX067,项目名称:fambom-svn-to-git,代码行数:29,代码来源:code_coverage_manager.php
示例9: paintMethodEnd
/**
* Paints the end of a test method being run. This is used
* to pause the collection of code coverage if its being used.
*
* @param string $method The name of the method being run.
* @return void
*/
function paintMethodEnd($method)
{
parent::paintMethodEnd($method);
if (!empty($this->params['codeCoverage'])) {
CodeCoverageManager::stop();
}
}
开发者ID:vinicius-ianni,项目名称:PHPMyScrum,代码行数:14,代码来源:cake_base_reporter.php
示例10: __run
/**
* Executes the tests depending on our settings
*
* @return void
* @access private
*/
function __run()
{
$reporter = new CLIReporter();
$this->__setGetVars();
if ($this->type == 'all') {
return TestManager::runAllTests($reporter);
}
if ($this->doCoverage) {
if (!extension_loaded('xdebug')) {
$this->out('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install');
exit(0);
}
}
if ($this->type == 'group') {
$ucFirstGroup = ucfirst($this->file);
$path = CORE_TEST_GROUPS;
if ($this->category == 'app') {
$path = APP_TEST_GROUPS;
} elseif ($this->isPluginTest) {
$path = APP . 'plugins' . DS . $this->category . DS . 'tests' . DS . 'groups';
}
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::start($ucFirstGroup, $reporter);
}
$result = TestManager::runGroupTest($ucFirstGroup, $reporter);
if ($this->doCoverage) {
CodeCoverageManager::report();
}
return $result;
}
$case = 'libs' . DS . $this->file . '.test.php';
if ($this->category == 'app') {
$case = $this->file . '.test.php';
} elseif ($this->isPluginTest) {
$case = $this->file . '.test.php';
}
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::start($case, $reporter);
}
$result = TestManager::runTestCase($case, $reporter);
if ($this->doCoverage) {
CodeCoverageManager::report();
}
return $result;
}
开发者ID:laiello,项目名称:myopensources,代码行数:53,代码来源:testsuite.php
示例11: __run
/**
* Executes the tests depending on our settings
*
* @return void
* @access private
*/
function __run()
{
$Reporter = new CakeCliReporter('utf-8', array('app' => $this->Manager->appTest, 'plugin' => $this->Manager->pluginTest, 'group' => $this->type === 'group', 'codeCoverage' => $this->doCoverage));
if ($this->type == 'all') {
return $this->Manager->runAllTests($Reporter);
}
if ($this->doCoverage) {
if (!extension_loaded('xdebug')) {
$this->out(__('You must install Xdebug to use the CakePHP(tm) Code Coverage Analyzation. Download it from http://www.xdebug.org/docs/install', true));
$this->_stop(0);
}
}
if ($this->type == 'group') {
$ucFirstGroup = ucfirst($this->file);
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::init($ucFirstGroup, $Reporter);
CodeCoverageManager::start();
}
$result = $this->Manager->runGroupTest($ucFirstGroup, $Reporter);
return $result;
}
$folder = $folder = $this->__findFolderByCategory($this->category);
$case = $this->__getFileName($folder, $this->isPluginTest);
if ($this->doCoverage) {
require_once CAKE . 'tests' . DS . 'lib' . DS . 'code_coverage_manager.php';
CodeCoverageManager::init($case, $Reporter);
CodeCoverageManager::start();
}
$result = $this->Manager->runTestCase($case, $Reporter);
return $result;
}
开发者ID:asairoha,项目名称:pj01,代码行数:38,代码来源:testsuite.php
示例12: __getTestFilesPath
/**
* Gets us the base path to look for the test files
*
* @param string $isApp
* @return void
* @access public
*/
function __getTestFilesPath($isApp = true)
{
$manager = CodeCoverageManager::getInstance();
$path = ROOT . DS;
if ($isApp) {
$path .= APP_DIR . DS;
} elseif (!!$manager->pluginTest) {
$path .= APP_DIR . DS . 'plugins' . DS . $manager->pluginTest . DS;
} else {
$path = TEST_CAKE_CORE_INCLUDE_PATH;
}
return $path;
}
开发者ID:BLisa90,项目名称:cakecart,代码行数:20,代码来源:code_coverage_manager.php
注:本文中的CodeCoverageManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论