当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_TestSuite::tests方法代码示例

本文整理汇总了PHP中PHPUnit_Framework_TestSuite::tests方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestSuite::tests方法的具体用法?PHP PHPUnit_Framework_TestSuite::tests怎么用?PHP PHPUnit_Framework_TestSuite::tests使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Framework_TestSuite的用法示例。


在下文中一共展示了PHPUnit_Framework_TestSuite::tests方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startTestSuite

 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());
                 }
             }
         }
         foreach ($suite->tests() as $test) {
             if ($test instanceof \PHPUnit_Framework_TestSuite && in_array('time-sensitive', \PHPUnit_Util_Test::getGroups($test->getName()), true)) {
                 ClockMock::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);
     }
 }
开发者ID:BatMatris,项目名称:symfony,代码行数:34,代码来源:SymfonyTestsListener.php

示例2: markTestsSkipped

 /**
  * Mark tests skipped
  *
  * @param TestCase $test
  * @param array $errors
  * @todo Mark tests skipped, unfortunately tests are skipped by invoking exceptions from the tests.
  */
 private function markTestsSkipped(TestCase $test, array $errors)
 {
     list($identifier, $className, $testName) = $this->storage->getTestIdentifiers($test);
     if ($this->mergeMode === self::MERGE_MODE_ERROR_AND_SKIP && count($errors) > 0 && count($this->suite->tests()) > count($errors) && $this->storage->getRecording(array(StorageInterface::STATUS_PASSED), $identifier)) {
         // mark test skipped. quite hard, cause skipped tests are handled through exceptions
     }
 }
开发者ID:petertilsen,项目名称:phpunit-clever-and-smart,代码行数:14,代码来源:Skipper.php

示例3: browserOnAllTests

 private function browserOnAllTests(PHPUnit_Framework_TestSuite $suite, array $browser)
 {
     foreach ($suite->tests() as $test) {
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             $this->browserOnAllTests($test, $browser);
         } else {
             $test->setupSpecificBrowser($browser);
         }
     }
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:10,代码来源:SeleniumBrowserSuite.php

示例4: startTestSuite

 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);
     }
 }
开发者ID:padraic,项目名称:phpunit-extensions,代码行数:11,代码来源:FilterListener.php

示例5: _getTests

 protected function _getTests(PHPUnit_Framework_TestSuite $suite)
 {
     $tests = array();
     foreach ($suite->tests() as $test) {
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             $tests = array_merge($tests, $this->_getTests($test));
         } else {
             $tests[] = $test;
         }
     }
     return $tests;
 }
开发者ID:66Ton99,项目名称:sfPhpunitPlugin,代码行数:12,代码来源:sfPhpunitBaseActions.class.php

示例6: extractSuite

 protected function extractSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $testList = $suite->tests();
     foreach ($testList as $test) {
         if ($test instanceof \PHPUnit_Framework_TestSuite) {
             $this->extractSuite($test);
         } else {
             $ref = new \ReflectionClass($test);
             self::addFile($ref);
         }
     }
 }
开发者ID:razielsd,项目名称:parallel-phpunit2,代码行数:12,代码来源:FileReader.php

示例7: endTestSuite

 /**
  * Clear test method properties after each test suite
  *
  * @param  PHPUnit_Framework_TestSuite $suite
  */
 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $tests = $suite->tests();
     foreach ($tests as $test) {
         $reflectionClass = new ReflectionClass($test);
         $properties = $reflectionClass->getProperties();
         foreach ($properties as $property) {
             $property->setAccessible(true);
             $value = $property->getValue($test);
             if (is_object($value) && method_exists($value, '__destruct')) {
                 $value->__destruct();
             }
             $property->setValue($test, null);
         }
     }
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:21,代码来源:ClearProperties.php

示例8: sortTestSuite

 private function sortTestSuite(TestSuite $suite)
 {
     $tests = $suite->tests();
     $testsOrderResult = array(static::SORT_NONE, null);
     foreach ($tests as $test) {
         if ($test instanceof TestCase && Util::getInvisibleProperty($test, 'dependencies', 'hasDependencies')) {
             return $testsOrderResult;
         }
     }
     $orderedTests = new SegmentedQueue($tests);
     $orderedTests->setMergeMode($this->mergeMode);
     foreach ($tests as $position => $test) {
         list($testOrderResult, $time) = $this->sortTest($test, $position, $orderedTests);
         if ($testsOrderResult[0] < $testOrderResult) {
             $testsOrderResult = array($testOrderResult, $time);
         }
     }
     $groups = Util::getInvisibleProperty($suite, 'groups', 'getGroupDetails');
     $groupsOrderResult = array(static::SORT_NONE, null);
     foreach ($groups as $groupName => $group) {
         $groupOrderResult = array(static::SORT_NONE, null);
         $orderedGroup = new SegmentedQueue($group);
         $orderedGroup->setMergeMode($this->mergeMode);
         foreach ($group as $position => $test) {
             list($testOrderResult, $time) = $this->sortTest($test, $position, $orderedGroup);
             if ($groupOrderResult[0] < $testOrderResult) {
                 $groupOrderResult = array($testOrderResult, $time);
             }
         }
         if ($groupOrderResult[0] > static::SORT_NONE) {
             $groups[$groupName] = iterator_to_array($orderedGroup);
             if ($groupsOrderResult[0] < $groupOrderResult[0]) {
                 $groupsOrderResult = $groupOrderResult;
             }
         }
     }
     if ($testsOrderResult[0] > static::SORT_NONE) {
         Util::setInvisibleProperty($suite, 'tests', iterator_to_array($orderedTests), 'setTests');
     }
     if ($groupsOrderResult) {
         Util::setInvisibleProperty($suite, 'groups', $groups, 'setGroupDetails');
     }
     return $testsOrderResult[0] > $groupsOrderResult[0] ? $testsOrderResult : $groupsOrderResult;
 }
开发者ID:petertilsen,项目名称:phpunit-clever-and-smart,代码行数:44,代码来源:PrioritySorter.php

示例9: endTestSuite

 public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     foreach ($suite->tests() as $test) {
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             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);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:20,代码来源:PlainPHPUnitResultFormatter.php

示例10: startTestSuite

    public function startTestSuite(\PHPUnit_Framework_TestSuite $mainSuite)
    {
        if (null !== self::$enabledPolyfills) {
            return;
        }
        self::$enabledPolyfills = false;
        foreach ($mainSuite->tests() as $suite) {
            $testClass = $suite->getName();
            if (!($tests = $suite->tests())) {
                continue;
            }
            if (!preg_match('/^(.+)\\\\Tests(\\\\.*)Test$/', $testClass, $m)) {
                $mainSuite->addTest(self::warning('Unknown naming convention for ' . $testClass));
                continue;
            }
            $testedClass = new \ReflectionClass($m[1] . $m[2]);
            $bootstrap = new \SplFileObject(dirname($testedClass->getFileName()) . '/bootstrap.php');
            $warnings = array();
            $defLine = null;
            foreach (new \RegexIterator($bootstrap, '/return p\\\\' . $testedClass->getShortName() . '::/') as $defLine) {
                if (!preg_match('/^\\s*function (?P<name>[^\\(]++)(?P<signature>\\([^\\)]*+\\)) \\{ (?<return>return p\\\\' . $testedClass->getShortName() . '::[^\\(]++)(?P<args>\\([^\\)]*+\\)); \\}$/', $defLine, $f)) {
                    $warnings[] = self::warning('Invalid line in bootstrap.php: ' . trim($defLine));
                    continue;
                }
                $testNamespace = substr($testClass, 0, strrpos($testClass, '\\'));
                if (function_exists($testNamespace . '\\' . $f['name'])) {
                    continue;
                }
                try {
                    $r = new \ReflectionFunction($f['name']);
                    if ($r->isUserDefined()) {
                        throw new \ReflectionException();
                    }
                    if (false !== strpos($f['signature'], '&')) {
                        $defLine = sprintf('return \\%s%s', $f['name'], $f['args']);
                    } else {
                        $defLine = sprintf("return \\call_user_func_array('%s', func_get_args())", $f['name']);
                    }
                } catch (\ReflectionException $e) {
                    $defLine = sprintf("throw new \\PHPUnit_Framework_SkippedTestError('Internal function not found: %s')", $f['name']);
                }
                eval(<<<EOPHP
namespace {$testNamespace};

use Symfony\\Polyfill\\Util\\TestListener;
use {$testedClass->getNamespaceName()} as p;

function {$f['name']}{$f['signature']}
{
    if ('{$testClass}' === TestListener::\$enabledPolyfills) {
        {$f['return']}{$f['args']};
    }

    {$defLine};
}
EOPHP
);
            }
            if (!$warnings && null === $defLine) {
                $warnings[] = new \PHPUnit_Framework_SkippedTestCase('No Polyfills found in bootstrap.php for ' . $testClass);
            } else {
                $mainSuite->addTest(new static($suite));
            }
        }
        foreach ($warnings as $w) {
            $mainSuite->addTest($w);
        }
    }
开发者ID:Kyra2778,项目名称:AMR,代码行数:68,代码来源:TestListener.php

示例11: __construct

 /**
  * Constructor.
  *
  * @param  PHPUnit_Framework_TestSuite $suite
  */
 public function __construct(PHPUnit_Framework_TestSuite $testSuite)
 {
     $this->tests = $testSuite->tests();
 }
开发者ID:xiplias,项目名称:pails,代码行数:9,代码来源:TestSuiteIterator.php

示例12: endTestSuite

 /**
  * Handler for 'endTestSuite' event
  *
  * @param \PHPUnit_Framework_TestSuite $suite
  */
 public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     $clearStatics = false;
     foreach ($suite->tests() as $test) {
         if ($test instanceof \Magento\TestFramework\TestCase\AbstractController) {
             $clearStatics = true;
             break;
         }
     }
     if ($clearStatics) {
         self::restoreStaticVariables();
     }
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:StaticProperties.php

示例13: filterTests

 /**
  * @param \PHPUnit_Framework_TestSuite $testSuite
  * @param integer $filter
  * @since Method available since Release 3.0.3
  */
 protected function filterTests(\PHPUnit_Framework_TestSuite $testSuite, $filter)
 {
     $filteredTests = array();
     foreach ($testSuite->tests() as $test) {
         if ($test instanceof \PHPUnit_Framework_TestCase) {
             $testClassName = get_class($test);
             $testMethodName = $test->getName(false);
             if ($this->testTargetRepository->shouldTreatElementAsTest($testClassName, $filter == self::$FILTER_METHOD ? $testMethodName : null)) {
                 $filteredTests[] = $test;
             }
         } else {
             $this->filterTests($test, $filter);
             if (count($test) > 0) {
                 $filteredTests[] = $test;
             }
         }
     }
     $testSuiteClass = new \ReflectionClass($testSuite);
     $testsProperty = $testSuiteClass->getProperty('tests');
     $testsProperty->setAccessible(true);
     $testsProperty->setValue($testSuite, $filteredTests);
     $testsProperty->setAccessible(false);
     $numTestsProperty = $testSuiteClass->getProperty('numTests');
     $numTestsProperty->setAccessible(true);
     $numTestsProperty->setValue($testSuite, -1);
     $numTestsProperty->setAccessible(false);
     $groupsProperty = $testSuiteClass->getProperty('groups');
     $groupsProperty->setAccessible(true);
     $groups = $groupsProperty->getValue($testSuite);
     $groups = array_map(function ($tests) use($filteredTests) {
         return array_filter($tests, function ($test) use($filteredTests) {
             return in_array($test, $filteredTests, true);
         });
     }, $groups);
     $groupsProperty->setValue($testSuite, $groups);
     $groupsProperty->setAccessible(false);
 }
开发者ID:rsky,项目名称:stagehand-testrunner,代码行数:42,代码来源:PHPUnitCollector.php

示例14: runTestCase

 /**
  * Runs a testcase as given in the GET/POST variable "testCaseFile".
  *
  * @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 runTestCase(PHPUnit_Framework_TestSuite $testSuiteWithAllTestCases, PHPUnit_Framework_TestResult $testResult)
 {
     $testCaseFileName = $this->request->getAsString(Tx_Phpunit_Interface_Request::PARAMETER_KEY_TESTCASE);
     $this->testListener->setTestSuiteName($testCaseFileName);
     $suiteNameHasBeenDisplayed = FALSE;
     $totalNumberOfTestCases = 0;
     foreach ($testSuiteWithAllTestCases->tests() as $testCases) {
         foreach ($testCases->tests() as $test) {
             if ($test instanceof PHPUnit_Framework_TestSuite) {
                 list($testIdentifier, $unused) = explode('::', $test->getName());
             } else {
                 $testIdentifier = get_class($test);
             }
             if ($testIdentifier === $testCaseFileName) {
                 if ($test instanceof PHPUnit_Framework_TestSuite) {
                     $totalNumberOfTestCases += $test->count();
                 } else {
                     $totalNumberOfTestCases++;
                 }
             }
         }
     }
     $this->testListener->setTotalNumberOfTests($totalNumberOfTestCases);
     $this->renderProgressbar();
     foreach ($testSuiteWithAllTestCases->tests() as $testCases) {
         foreach ($testCases->tests() as $test) {
             if ($test instanceof PHPUnit_Framework_TestSuite) {
                 list($testIdentifier, $unused) = explode('::', $test->getName());
             } else {
                 $testIdentifier = get_class($test);
             }
             if ($testIdentifier === $testCaseFileName) {
                 if (!$suiteNameHasBeenDisplayed) {
                     $this->outputService->output('<h2 class="testSuiteName">Testsuite: ' . $testCaseFileName . '</h2>');
                     $suiteNameHasBeenDisplayed = TRUE;
                 }
                 $test->run($testResult);
             }
         }
     }
     if (!is_object($testResult)) {
         $this->outputService->output('<h2 class="hadError">Error</h2><p>The test <strong> ' . htmlspecialchars($this->request->getAsString(Tx_Phpunit_Interface_Request::PARAMETER_KEY_TEST)) . '</strong> could not be found.</p>');
         return;
     }
 }
开发者ID:chrmue01,项目名称:typo3-starter-kit,代码行数:53,代码来源:Module.php

示例15: testMessageNameForTestWithDataProvider

    public function testMessageNameForTestWithDataProvider()
    {
        $theClass = new \ReflectionClass('\\PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest');
        $testSuite = new \PHPUnit_Framework_TestSuite($theClass);
        $tests = $testSuite->tests();
        $this->assertArrayHasKey(0, $tests);
        $this->assertInstanceOf('PHPUnit_Framework_TestSuite_DataProvider', $tests[0]);
        /* @var \PHPUnit_Framework_TestSuite_DataProvider $dataProviderTestSuite */
        $dataProviderTestSuite = $tests[0];
        $this->assertArrayHasKey(1, $tests);
        $this->assertInstanceOf('\\PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest', $tests[1]);
        /* @var DataProviderTest $simpleMethodTest*/
        $simpleMethodTest = $tests[1];
        $this->listener->startTestSuite($testSuite);
        $this->listener->startTestSuite($dataProviderTestSuite);
        foreach ($dataProviderTestSuite as $test) {
            $this->listener->startTest($test);
            $this->listener->endTest($test, 5);
        }
        $this->listener->endTestSuite($dataProviderTestSuite);
        $this->listener->startTest($simpleMethodTest);
        $this->listener->endTest($simpleMethodTest, 6);
        $this->listener->endTestSuite($testSuite);
        $expectedOutput = <<<EOS
##teamcity[testSuiteStarted name='PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testSuiteStarted name='PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest::testMethodWithDataProvider' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testMethodWithDataProvider with data set "one"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='5000' name='testMethodWithDataProvider with data set "one"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testMethodWithDataProvider with data set "two"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='5000' name='testMethodWithDataProvider with data set "two"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testMethodWithDataProvider with data set "three"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='5000' name='testMethodWithDataProvider with data set "three"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testMethodWithDataProvider with data set "four"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='5000' name='testMethodWithDataProvider with data set "four"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testMethodWithDataProvider with data set "five.one"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='5000' name='testMethodWithDataProvider with data set "five.one"' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testSuiteFinished name='PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest::testMethodWithDataProvider' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testStarted captureStandardOutput='true' name='testSimpleMethod' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testFinished duration='6000' name='testSimpleMethod' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']
##teamcity[testSuiteFinished name='PHPUnit\\TeamCity\\Tests\\Fixtures\\DataProviderTest' timestamp='2015-05-28T16:14:12.17+0700' flowId='24107']

EOS;
        $this->assertOutputSame($expectedOutput);
    }
开发者ID:munkie,项目名称:phpunit-teamcity-testlistener,代码行数:44,代码来源:TestListenerTest.php


注:本文中的PHPUnit_Framework_TestSuite::tests方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。