getName() public method

Returns the name of the suite.
public getName ( ) : string
return string
 /**
  * Determine the "full" test name (including the suite name if it is set)
  *
  * @param \PHPUnit_Framework_TestCase $test
  * @return string
  */
 private function getCurrentTestName(\PHPUnit_Framework_TestCase $test)
 {
     if (null === $this->currentSuite) {
         return $test->getName(true);
     }
     return $this->currentSuite->getName() . '::' . $test->getName(true);
 }
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $this->suiteLevel++;
     $this->currentSuiteName = $suite->getName();
     if ($this->suiteLevel == 1 + $this->rootSuiteNestingLevel) {
         $this->rootSuiteName = $suite->getName();
         $suites = $suite->tests();
         $filtered = $this->filterSuites($suites);
         $suite->setTests($filtered);
     }
 }
Example #3
0
 /**
  * A test suite started.
  *
  * @param  PHPUnit_Framework_TestSuite $suite
  * @since  Method available since Release 2.2.0
  */
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $this->writeOutput($suite->getName() . "\n");
     $this->resetLength();
     $i = 0;
     while ($i != strlen($suite->getName())) {
         $this->writeOutput("-");
         $i++;
     }
     $this->writeOutput("\n");
     $this->resetLength();
 }
Example #4
0
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $this->printUnlessIgnore($suite->getName(), sprintf(" Finished in %.6fs", $this->totalTime));
     $msgIndex = 1;
     foreach (array_merge($this->errorMessages, $this->failureMessages) as $message) {
         $this->printUnlessIgnore($suite->getName(), "\n\n" . $msgIndex++ . ") " . $message);
     }
     if ($this->errors || $this->failures) {
         $color = "[0;31m";
     } else {
         $color = "[0;32m";
     }
     $results = sprintf("\n\n%s\n%d tests, ? assertions, %d failures, %d errors\n\n", str_repeat('=', 80), $this->tests, $this->failures, $this->errors);
     $this->printUnlessIgnore($suite->getName(), chr(27) . $color . $results . chr(27) . chr(27) . "[0m");
 }
Example #5
0
    public function __construct(PHPUnit_Framework_TestSuite $suite, array $groups)
    {
        $groupSuites = array();
        $name        = $suite->getName();

        foreach ($groups as $group) {
            $groupSuites[$group] = new PHPUnit_Framework_TestSuite($name . ' - ' . $group);
            $this->addTest($groupSuites[$group]);
        }

        $tests = new RecursiveIteratorIterator(
          new PHPUnit_Util_TestSuiteIterator($suite),
          RecursiveIteratorIterator::LEAVES_ONLY
        );

        foreach ($tests as $test) {
            if ($test instanceof PHPUnit_Framework_TestCase) {
                $testGroups = PHPUnit_Util_Test::getGroups(
                  get_class($test), $test->getName(FALSE)
                );

                foreach ($groups as $group) {
                    foreach ($testGroups as $testGroup) {
                        if ($group == $testGroup) {
                            $groupSuites[$group]->addTest($test);
                        }
                    }
                }
            }
        }
    }
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $suiteName = $suite->getName();
     if (-1 === $this->state) {
         echo "Testing {$suiteName}\n";
         $this->state = 0;
         if (!class_exists('Doctrine\\Common\\Annotations\\AnnotationRegistry', false) && class_exists('Doctrine\\Common\\Annotations\\AnnotationRegistry')) {
             AnnotationRegistry::registerLoader('class_exists');
         }
         if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
             $this->state = 1;
             if (file_exists($this->skippedFile)) {
                 $this->state = 2;
                 if (!($this->wasSkipped = (require $this->skippedFile))) {
                     echo "All tests already ran successfully.\n";
                     $suite->setTests(array());
                 }
             }
         }
     } elseif (2 === $this->state) {
         $skipped = array();
         foreach ($suite->tests() as $test) {
             if (!$test instanceof \PHPUnit_Framework_TestCase || isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName][$test->getName()])) {
                 $skipped[] = $test;
             }
         }
         $suite->setTests($skipped);
     }
 }
Example #7
0
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if ($this->maxLength == 0) {
         $iterator = new RecursiveIteratorIterator(new PHPUnit_Util_TestSuiteIterator($suite), RecursiveIteratorIterator::SELF_FIRST);
         foreach ($iterator as $item) {
             if ($item instanceof PHPUnit_Framework_TestSuite) {
                 $name = $item->getName();
                 if ($name == '') {
                     $name = '[No name given]';
                 } else {
                     $name = explode('::', $name);
                     $name = array_pop($name);
                 }
                 $this->maxLength = max($this->maxLength, strlen($name));
                 $item->setName($name);
             }
         }
     }
     if ($this->depth > 0) {
         parent::write("\n");
     }
     if ($this->depth == 1) {
         parent::write("\n");
     }
     parent::write(str_pad(str_repeat('  ', $this->depth++) . $suite->getName() . ': ', 40, ' ', STR_PAD_RIGHT));
 }
Example #8
0
 public function __construct(\PHPUnit_Framework_TestSuite $suite = null)
 {
     if ($suite) {
         $this->suite = $suite;
         $this->setName($suite->getName() . ' with polyfills enabled');
         $this->addTest($suite);
     }
 }
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $name = $suite->getName();
     if (!$this->isValidClass($name)) {
         return;
     }
     $this->class->tearDownOnce();
 }
 protected function isClassTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $suite_name = $suite->getName();
     if (!empty($suite_name) && class_exists($suite_name, false)) {
         return true;
     }
     return false;
 }
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $this->logger->write('Testsuite ' . $suite->getName() . ' ended.');
     if ($this->tests_ok > 0 || $this->tests_failed > 0) {
         $this->logger->write(' OK: ' . $this->tests_ok . ' Failed: ' . $this->tests_failed);
     }
     $this->tests_ok = 0;
     $this->tests_failed = 0;
 }
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if ($this->cleanStorages() && $this->isShowSuiteWarning()) {
         printf("TestSuite '%s': Did not clean up storages\n", $suite->getName());
     }
     if ($this->cleanFileCache() && $this->isShowSuiteWarning()) {
         printf("TestSuite '%s': Did not clean up file cache\n", $suite->getName());
     }
     if ($this->cleanStrayDataFiles() && $this->isShowSuiteWarning()) {
         printf("TestSuite '%s': Did not clean up data dir\n", $suite->getName());
     }
     if ($this->cleanStrayHooks() && $this->isShowSuiteWarning()) {
         printf("TestSuite '%s': Did not clean up hooks\n", $suite->getName());
     }
     if ($this->cleanProxies() && $this->isShowSuiteWarning()) {
         printf("TestSuite '%s': Did not clean up proxies\n", $suite->getName());
     }
 }
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if ($suite->getName() == 'AllTests') {
         return false;
     }
     $sb = "Testsuite: " . $suite->getName() . "\n";
     $sb .= "Tests run: " . $this->getRunCount();
     $sb .= ", Failures: " . $this->getFailureCount();
     $sb .= ", Errors: " . $this->getErrorCount();
     $sb .= ", Incomplete: " . $this->getIncompleteCount();
     $sb .= ", Skipped: " . $this->getSkippedCount();
     $sb .= ", Time elapsed: " . sprintf('%0.5f', $this->getElapsedTime()) . " s\n";
     if ($this->out != NULL) {
         $this->out->write($sb);
         $this->out->write($this->inner);
     }
     parent::endTestSuite($suite);
 }
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $name = str_replace("_", ".", strtolower($suite->getName()));
     echo "\n";
     echo str_repeat('-', 180);
     echo "\n>>> startTestSuite: " . $name;
     //echo 'starting test suite. First, clearing all test statistics';
     //printf("TestSuite '%s' started.\n", $suite->getName());
 }
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if (!static::$enableDurationCapture) {
         return;
     }
     if (!class_exists($suite->getName())) {
         return;
     }
     static::$durationByTest[$suite->getName()]['time'] = microtime(true) - static::$durationByTest[$suite->getName()]['time'];
 }
 /**
  * Performs individual test-suite-specific actions.
  *
  * This gets triggered by PHPUnit when a new test suite gets run.
  *
  * @since 1.0.0
  *
  * @param PHPUnit_Framework_TestSuite $suite Test suite object.
  *
  * @return void
  */
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     switch (strtolower($suite->getName())) {
         case 'unit':
             $this->autoload_stubs();
             break;
         case 'integration':
             $this->autoload_stubs();
             break;
     }
 }
Example #17
0
 /**
  * Performs individual test-suite-specific actions.
  *
  * This gets triggered by PHPUnit when a new test suite gets run.
  *
  * @since 1.0.0
  *
  * @param PHPUnit_Framework_TestSuite $suite Test suite object.
  */
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     switch ($suite->getName()) {
         case 'Unit':
             // TODO: Some unit testing preparations...
             break;
         case 'Integration':
             // TODO: Some integration testing preparations...
             break;
     }
 }
Example #18
0
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     // don't clean up the test environment if a data provider finished
     if (!$suite instanceof PHPUnit_Framework_TestSuite_DataProvider) {
         if ($this->cleanStorages() && $this->isShowSuiteWarning()) {
             printf("TestSuite '%s': Did not clean up storages\n", $suite->getName());
         }
         if ($this->cleanFileCache() && $this->isShowSuiteWarning()) {
             printf("TestSuite '%s': Did not clean up file cache\n", $suite->getName());
         }
         if ($this->cleanStrayDataFiles() && $this->isShowSuiteWarning()) {
             printf("TestSuite '%s': Did not clean up data dir\n", $suite->getName());
         }
         if ($this->cleanStrayHooks() && $this->isShowSuiteWarning()) {
             printf("TestSuite '%s': Did not clean up hooks\n", $suite->getName());
         }
         if ($this->cleanProxies() && $this->isShowSuiteWarning()) {
             printf("TestSuite '%s': Did not clean up proxies\n", $suite->getName());
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     // Use a static so we only do this test once after all the data providers
     // have run.
     static $tested = FALSE;
     if ($suite->getName() !== '' && !$tested) {
         $tested = TRUE;
         if (!empty(SafeMarkup::getAll())) {
             throw new \RuntimeException('SafeMarkup string list polluted by data providers');
         }
     }
 }
Example #20
0
 /**
  * Determine if test suite is an integration test suite.
  *
  * @param PHPUnit_Framework_TestSuite $testSuite Test suite
  * @param bool True if suite/test is starting; false otherwise
  * @return bool True if integration suite/test; false otherwise.
  */
 private function isIntegrationSuiteOrTest(PHPUnit_Framework_TestSuite $testSuite, $isStarting)
 {
     // Determine if the suite/test name should be initialized
     if ($isStarting) {
         // Determine if the suite/test is the setup suite/test
         if (self::$endingSuiteTestName == "") {
             // Determine if this is a test suite or integration test
             $name = $testSuite->getName();
             if (strpos($name, "integration") !== false) {
                 // Test suite
                 self::$endingSuiteTestName = $name;
                 return true;
             } else {
                 if (strpos(strtolower($name), "integration") !== false || is_file($name = end($_SERVER['argv']))) {
                     if (strpos(strtolower($name), "integration") !== false) {
                         // Integration test
                         self::$endingSuiteTestName = $name;
                         return true;
                     }
                 }
             }
         }
     } else {
         // Determine if the suite/test is the teardown suite/test
         if (self::$endingSuiteTestName != "") {
             if ($testSuite->getName() == self::$endingSuiteTestName || end($_SERVER['argv']) == self::$endingSuiteTestName) {
                 // Teardown suite/test
                 self::$endingSuiteTestName = "";
                 return true;
             }
         }
     }
     /*
      * Unable to determine if suite/test is for integration purposes or the
      * suite/test has already been initialized
      */
     return false;
 }
 public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     /**
      * Only log Level 2 test suites, i.e. your actual test classes. Level 1
      * is the parent root suite(s) defined in the XML config and Level 3 are
      * those hosting data provider tests.
      */
     if ($this->suiteLevel !== 2 + $this->rootSuiteNestingLevel) {
         $this->suiteLevel--;
         return;
     }
     $this->suiteLevel--;
     $this->logger->logTestSuite($suite->getName(), $this->currentSuiteTime);
     $this->currentSuiteTime = 0;
 }
 function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $sb = "Test: " . $suite->getName();
     $sb .= ", Run: " . $this->getRunCount();
     $sb .= ", Failures: " . $this->getFailureCount();
     $sb .= ", Errors: " . $this->getErrorCount();
     $sb .= ", Incomplete: " . $this->getIncompleteCount();
     $sb .= ", Skipped: " . $this->getSkippedCount();
     $sb .= ", Time elapsed: " . sprintf('%0.5f', $this->getElapsedTime()) . " s\n";
     parent::endTestSuite($suite);
     if ($this->out != NULL) {
         $this->out->write($sb);
         $this->out->close();
     }
 }
 /**
  * @param \PHPUnit_Framework_TestSuite $suite
  */
 public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     printf("\nEnded testsuite '%s\n", $suite->getName());
     // Stop Stopwatch for the current test
     if ($this->profileWithStopwatch) {
         $event = $this->getStopwatch()->stop($suite->getName());
     }
     // Output detailed memory profiling
     if ($this->profileMemoryUsage) {
         printf('Memory: ');
         if ($this->profileMemoryUsage) {
             printf(' Currently used: %s; ', $this->getCurrentMemoryUsed());
         }
         if ($this->profileMemoryDetailedUsage) {
             printf(' Increased by this test suite: %s; ', $this->calculateIncreaseInMemoryUseSinceLastTestsuite());
         }
         printf("\n");
     }
     // Output time profiling
     if ($this->profileTime) {
         printf('Time took: ');
         // Output time profiling with PHPUnit
         if ($this->profileTimeWithPhpunit) {
             printf(' PHPUnit: N/A for a test suite; ');
         }
         // Output time profiling with Stopwatch
         if ($this->profileTimeWithStopwatch && isset($event)) {
             printf(' Stopwatch: %s ms;', $event->getDuration());
         }
         printf("\n");
         // Freeup memory
         if (isset($event)) {
             $event = null;
         }
     }
 }
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $suiteName = $suite->getName();
     if (-1 === $this->state) {
         echo "Testing {$suiteName}\n";
         $this->state = 0;
         if (!class_exists('Doctrine\\Common\\Annotations\\AnnotationRegistry', false) && class_exists('Doctrine\\Common\\Annotations\\AnnotationRegistry')) {
             AnnotationRegistry::registerLoader('class_exists');
         }
         if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) {
             $this->state = 1;
             if (file_exists($this->skippedFile)) {
                 $this->state = 2;
                 if (!($this->wasSkipped = (require $this->skippedFile))) {
                     echo "All tests already ran successfully.\n";
                     $suite->setTests(array());
                 }
             }
         }
         $testSuites = array($suite);
         for ($i = 0; isset($testSuites[$i]); ++$i) {
             foreach ($testSuites[$i]->tests() as $test) {
                 if ($test instanceof \PHPUnit_Framework_TestSuite) {
                     if (!class_exists($test->getName(), false)) {
                         $testSuites[] = $test;
                         continue;
                     }
                     $groups = \PHPUnit_Util_Test::getGroups($test->getName());
                     if (in_array('time-sensitive', $groups, true)) {
                         ClockMock::register($test->getName());
                     }
                     if (in_array('dns-sensitive', $groups, true)) {
                         DnsMock::register($test->getName());
                     }
                 }
             }
         }
     } elseif (2 === $this->state) {
         $skipped = array();
         foreach ($suite->tests() as $test) {
             if (!$test instanceof \PHPUnit_Framework_TestCase || isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName][$test->getName()])) {
                 $skipped[] = $test;
             }
         }
         $suite->setTests($skipped);
     }
 }
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if (strpos($suite->getName(), 'KunstmaanTranslationBundle') === false) {
         return true;
     }
     $kernel = new \AppKernel('phpunit', true);
     $kernel->boot();
     // drop/create database schema
     $em = $kernel->getContainer()->get('doctrine.orm.default_entity_manager');
     $meta = $em->getMetadataFactory()->getAllMetadata();
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $tool->dropSchema($meta);
     $tool->createSchema($meta);
     // insert fixtures
     $fixtures = array(__DIR__ . '/files/fixtures.yml');
     $em = $kernel->getContainer()->get('doctrine.orm.default_entity_manager');
     $objects = \Nelmio\Alice\Fixtures::load($fixtures, $em);
     $persister = new \Nelmio\Alice\ORM\Doctrine($em);
     $persister->persist($objects);
 }
Example #26
0
 /**
  * @param \PHPUnit_Framework_TestSuite $suite
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     switch ($suite->getName()) {
         case "unit":
         case "integration":
         case "acceptance":
         case "functional":
             echo "\nRunning {$suite->getName()} tests\n";
             if (file_exists(getcwd() . "/tests/{$suite->getName()}/bootstrap.php")) {
                 require getcwd() . "/tests/{$suite->getName()}/bootstrap.php";
             } else {
                 if (file_exists(getcwd() . "/tests/bootstrap-{$suite->getName()}.php")) {
                     require getcwd() . "/tests/bootstrap-{$suite->getName()}.php";
                 }
             }
     }
 }
 /**
  * Upon completion of a test suite adds the suite to the suties performed
  *
  * @param PHPUnit_Framework_TestSuite $suite current suite that is being run
  */
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if (strlen($suite->getName())) {
         $this->endCurrentTestSuite();
     }
 }
 /**
  * A testsuite started.
  *
  * @param  PHPUnit_Framework_TestSuite $suite
  */
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $this->currentTestSuiteName = $suite->getName();
     $this->currentTestName = '';
     $this->write(sprintf('suite started: %s (%d test%s)', $this->currentTestSuiteName, count($suite), count($suite) == 1 ? '' : 's'));
 }
 /**
  * A testsuite started.
  *
  * @param PHPUnit_Framework_TestSuite $suite
  * @return void
  * @author Karsten Dambekalns <*****@*****.**>
  * @author Christopher Hlubek <*****@*****.**>
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $suiteName = $suite->getName();
     $suiteParts = explode('\\', $suiteName);
     $suiteClassName = '';
     for ($i = 0; $i < count($suiteParts); $i++) {
         $suitePart = $suiteParts[$i];
         if ($suiteClassName !== '') {
             $suiteClassName .= '\\' . $suitePart;
         } else {
             $suiteClassName = $suitePart;
         }
         if ($i < count($suiteParts) - 1) {
             $suiteClassNameFilter = $suiteClassName . '\\.*Test';
         } else {
             $suiteClassNameFilter = $suiteClassName;
         }
         $suiteLinks[] = '<a href="testing/?packageToTest=' . urlencode('*') . '&testCaseClassName=' . urlencode($suiteClassNameFilter) . '&' . http_build_query(array('testTypes' => $_REQUEST['testTypes'])) . '">' . $suitePart . '</a>';
     }
     echo '<div class="testsuite"><h2 class="testsuite">' . implode(' \\ ', $suiteLinks) . '</h2>';
     $this->resultArray = array('total' => 0, 'skipped' => 0, 'incomplete' => 0, 'failure' => 0, 'error' => 0);
 }
 /**
  * Upon completion of a test suite adds the suite to the suties performed
  * 
  * @access public
  * @param obj PHPUnit_Framework_TestSuite, current suite that is being run
  * @return void
  */
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if (strlen($suite->getName())) {
         array_push($this->suiteResults['suites'], $this->currentSuite);
     }
 }