示例#1
0
 /**
  * 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();
     }
 }
 /**
  * testNoTestCaseSupplied method
  *
  * @access public
  * @return void
  */
 function testNoTestCaseSupplied()
 {
     if (PHP_SAPI != 'cli') {
         unset($_GET['group']);
         CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
         CodeCoverageManager::report(false);
         $this->assertError();
         CodeCoverageManager::start('libs/' . basename(__FILE__), new CakeHtmlReporter());
         CodeCoverageManager::report(false);
         $this->assertError();
         $path = LIBS;
         if (strpos(LIBS, ROOT) === false) {
             $path = ROOT . DS . LIBS;
         }
         App::import('Core', 'Folder');
         $folder = new Folder();
         $folder->cd($path);
         $contents = $folder->ls();
         /**
          * remove method
          *
          * @param mixed $var
          * @access public
          * @return void
          */
         function remove($var)
         {
             return $var != basename(__FILE__);
         }
         $contents[1] = array_filter($contents[1], "remove");
         foreach ($contents[1] as $file) {
             CodeCoverageManager::start('libs' . DS . $file, new CakeHtmlReporter());
             CodeCoverageManager::report(false);
             $this->assertNoErrors('libs' . DS . $file);
         }
     }
 }
示例#3
0
 /**
  * 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();
 }
 /**
  * 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();
     }
 }
示例#5
0
    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;
示例#6
0
 /**
  * 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;
 }
 /**
  * Test that test cases don't cause errors
  *
  * @return void
  */
 function testNoTestCaseSuppliedNoErrors()
 {
     if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
         return;
     }
     $reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
     $path = LIBS;
     if (strpos(LIBS, ROOT) === false) {
         $path = ROOT . DS . LIBS;
     }
     App::import('Core', 'Folder');
     $folder = new Folder();
     $folder->cd($path);
     $contents = $folder->read();
     $contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));
     foreach ($contents[1] as $file) {
         CodeCoverageManager::init('libs' . DS . $file, $reporter);
         CodeCoverageManager::report(false);
         $this->assertNoErrors('libs' . DS . $file);
     }
 }