count() public method

Counts the number of test cases that will be run by this test.
public count ( boolean $preferCache = false ) : integer
$preferCache boolean Indicates if cache is preferred.
return integer
 /**
  * A test suite started.
  *
  * @param \PHPUnit_Framework_TestSuite $suite
  *
  * @return void
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $suiteName = $suite->getName();
     $testCount = $suite->count();
     $context = array('suiteName' => $suiteName, 'testCount' => $testCount, 'operation' => __FUNCTION__);
     $this->suites[] = $suiteName;
     $this->stats[$suiteName] = array('tests' => 0, 'assertions' => 0, 'failures' => 0, 'errors' => 0, 'incompletes' => 0, 'skips' => 0, 'risky' => 0);
     $this->logger->notice(sprintf("TestSuite '%s' started with %d tests.", $suiteName, $testCount), $context);
 }
Example #2
0
 public static function buildAndAddSuiteFromDirectory2($parentSuite, $name, $directoryName, $whatToTest)
 {
     assert('is_string($directoryName) && $directoryName != ""');
     if (is_dir($directoryName)) {
         $suite = new PHPUnit_Framework_TestSuite();
         $suite->setName(ucfirst($name) . ' Tests');
         $fileNames = scandir($directoryName);
         foreach ($fileNames as $fileName) {
             if (substr($fileName, strlen($fileName) - strlen('Test.php')) == 'Test.php') {
                 require_once "{$directoryName}/{$fileName}";
                 $className = substr($fileName, 0, strlen($fileName) - 4);
                 if (substr($className, strlen($className) - 8) != 'BaseTest') {
                     if ($whatToTest == 'All' || $whatToTest == 'Framework' && $name == 'Framework' || $whatToTest == 'Misc' && $name == 'Misc' || $whatToTest == 'BadDependencies' && $name == 'BadDependencies' || $whatToTest == $name || $whatToTest == $className) {
                         if (@class_exists($className, false)) {
                             $suite->addTestSuite(new PHPUnit_Framework_TestSuite($className));
                             static::resolveDependentTestModelClassNamesForClass($className, $directoryName);
                         }
                     }
                 }
             }
         }
         if ($suite->count() > 0) {
             $parentSuite->addTestSuite($suite);
         }
     }
 }
Example #3
0
 /**
  * Runs all tests.
  *
  * @param PHPUnit_Framework_TestSuite $testSuiteWithAllTestCases suite with all test cases
  * @param PHPUnit_Framework_TestResult $testResult the test result (will be modified)
  *
  * @return void
  */
 protected function runAllTests(PHPUnit_Framework_TestSuite $testSuiteWithAllTestCases, PHPUnit_Framework_TestResult $testResult)
 {
     $this->testListener->setTotalNumberOfTests($testSuiteWithAllTestCases->count());
     $this->renderProgressbar();
     $testSuiteWithAllTestCases->run($testResult);
 }