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


PHP PHPUnit_Util_Test类代码示例

本文整理汇总了PHP中PHPUnit_Util_Test的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Util_Test类的具体用法?PHP PHPUnit_Util_Test怎么用?PHP PHPUnit_Util_Test使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: shouldExclude

 /**
  * @param ReflectionClass $theClass
  * @param Stagehand_TestRunner_Config $config
  * @return boolean
  */
 protected function shouldExclude(ReflectionClass $class, ReflectionMethod $method)
 {
     if (is_null($this->config->phpunitConfigFile)) {
         return false;
     }
     $groups = PHPUnit_Util_Test::getGroups($class->getName(), $method->getName());
     $shouldExclude = false;
     $groupConfiguration = PHPUnit_Util_Configuration::getInstance($this->config->phpunitConfigFile)->getGroupConfiguration();
     if (array_key_exists('include', $groupConfiguration) && count($groupConfiguration['include'])) {
         $shouldExclude = true;
         foreach ($groups as $group) {
             if (in_array($group, $groupConfiguration['include'])) {
                 $shouldExclude = false;
                 break;
             }
         }
     }
     if (array_key_exists('exclude', $groupConfiguration) && count($groupConfiguration['exclude'])) {
         foreach ($groups as $group) {
             if (in_array($group, $groupConfiguration['exclude'])) {
                 $shouldExclude = true;
                 break;
             }
         }
     }
     return $shouldExclude;
 }
开发者ID:rsky,项目名称:makegood,代码行数:32,代码来源:PHPUnitGroupFilterTestSuite.php

示例2: tearDown

 public function tearDown()
 {
     $doc = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($this), $this->getName(false));
     if (isset($doc['method']['memcheck'])) {
         $memory = 0;
         // allocate variable
         $zero = 0;
         // allocate zero value
         $r = array(0, 0, 0);
         // allocate result
         for ($i = 0; $i < 3; $i++) {
             $memory = memory_get_usage(0);
             $this->data = [];
             $this->runTest();
             unset($this->data);
             ION::dispatch(ION::LOOP_NONBLOCK | ION::LOOP_ONCE);
             // ammm, i think libevent free unpinned data-chunks in the loop (todo: analyze it)
             $r[$i] = memory_get_usage(0) - $memory;
             if ($r[$i] < 0) {
                 // free memory possible
                 $r[$i] = $zero;
                 // this hack remove 8-bytes-memory-leak
             }
         }
         if (array_sum($r)) {
             $this->fail("Memory leak detected: +" . implode(" B, +", $r) . " B");
         }
     }
 }
开发者ID:php-ion,项目名称:php-ion,代码行数:29,代码来源:TestCase.php

示例3: __construct

 /**
  * Constructor adds test groups defined on global level
  * and adds additional logic for test names retrieval
  *
  * @see PHPUnit_Framework_TestSuite::__construct()
  */
 public function __construct($theClass = '', $groups = array())
 {
     if (!$theClass instanceof ReflectionClass) {
         $theClass = EcomDev_Utils_Reflection::getReflection($theClass);
     }
     // Check annotations for test case name
     $annotations = PHPUnit_Util_Test::parseTestMethodAnnotations($theClass->getName());
     if (isset($annotations['name'])) {
         $this->suiteName = $annotations['name'];
     }
     // Creates all test instances
     parent::__construct($theClass);
     // Just sort-out them by our internal groups
     foreach ($groups as $group) {
         $this->groups[$group] = $this->tests();
     }
     foreach ($this->tests() as $test) {
         if ($test instanceof PHPUnit_Framework_TestSuite) {
             /* @todo
              * Post an issue into PHPUnit bugtracker for
              * impossibility for specifying group by parent test case
              * Because it is a very dirty hack :(
              **/
             $testGroups = array();
             foreach ($groups as $group) {
                 $testGroups[$group] = $test->tests();
             }
             EcomDev_Utils_Reflection::setRestrictedPropertyValue($test, 'groups', $testGroups);
         }
     }
     // Remove un grouped tests group, if it exists
     if (isset($this->groups[self::NO_GROUP_KEYWORD])) {
         unset($this->groups[self::NO_GROUP_KEYWORD]);
     }
 }
开发者ID:cmuench,项目名称:EcomDev_PHPUnit,代码行数:41,代码来源:Group.php

示例4: setUp

 /**
  * Start and clear caching proxy server if test is annotated with @clearCache
  */
 protected function setUp()
 {
     $annotations = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($this), $this->getName());
     if (isset($annotations['class']['clearCache']) || isset($annotations['method']['clearCache'])) {
         $this->getProxy()->clear();
     }
 }
开发者ID:benr77,项目名称:FOSHttpCacheBundle,代码行数:10,代码来源:ProxyTestCase.php

示例5: beforeClass

 public function beforeClass(SuiteEvent $e)
 {
     foreach ($e->getSuite()->tests() as $test) {
         /** @var $test \PHPUnit_Framework_Test  * */
         $testClass = get_class($test);
         $this->hooks[$testClass] = \PHPUnit_Util_Test::getHookMethods($testClass);
     }
     $this->runHooks('beforeClass');
 }
开发者ID:codeception,项目名称:base,代码行数:9,代码来源:BeforeAfterTest.php

示例6: executeAfterMethods

 protected function executeAfterMethods($testMethod, $I)
 {
     $annotations = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($this->testClassInstance), $testMethod);
     if (!empty($annotations['method']['after'])) {
         foreach ($annotations['method']['after'] as $m) {
             $this->executeContextMethod(trim($m), $I);
         }
     }
 }
开发者ID:corcre,项目名称:elabftw,代码行数:9,代码来源:Cest.php

示例7: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName());
         if (in_array('time-sensitive', $groups, true)) {
             ClockMock::withClockMock(false);
         }
     }
 }
开发者ID:nquicenob,项目名称:symfony,代码行数:9,代码来源:SymfonyTestsListener.php

示例8: makeSuite

 protected static function makeSuite($className, $group = null)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName($className);
     $class = new ReflectionClass($className);
     $parser = new Parser();
     $parser->startExternalParse(Title::newMainPage(), new ParserOptions(), Parser::OT_HTML, true);
     foreach (self::$engineConfigurations as $engineName => $opts) {
         if ($group !== null && $group !== $engineName) {
             continue;
         }
         try {
             $engineClass = "Scribunto_{$engineName}Engine";
             $engine = new $engineClass(self::$engineConfigurations[$engineName] + array('parser' => $parser));
             $engine->setTitle($parser->getTitle());
             $engine->getInterpreter();
         } catch (Scribunto_LuaInterpreterNotFoundError $e) {
             $suite->addTest(new $className('skipUnavailable', array(), '', $engineName), array('Lua', $engineName));
             continue;
         }
         // Work around PHPUnit breakage: the only straightforward way to
         // get the data provider is to call
         // PHPUnit_Util_Test::getProvidedData, but that instantiates the
         // class without passing any parameters to the constructor. But we
         // *need* that engine name.
         self::$staticEngineName = $engineName;
         $engineSuite = new PHPUnit_Framework_TestSuite();
         $engineSuite->setName("{$engineName}: {$className}");
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $groups = PHPUnit_Util_Test::getGroups($className, $name);
                 $groups[] = 'Lua';
                 $groups[] = $engineName;
                 $groups = array_unique($groups);
                 $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                 if (is_array($data) || $data instanceof Iterator) {
                     // with @dataProvider
                     $dataSuite = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                     foreach ($data as $k => $v) {
                         $dataSuite->addTest(new $className($name, $v, $k, $engineName), $groups);
                     }
                     $engineSuite->addTest($dataSuite);
                 } elseif ($data === false) {
                     // invalid @dataProvider
                     $engineSuite->addTest(new PHPUnit_Framework_Warning("The data provider specified for {$className}::{$name} is invalid."));
                 } else {
                     // no @dataProvider
                     $engineSuite->addTest(new $className($name, array(), '', $engineName), $groups);
                 }
             }
         }
         $suite->addTest($engineSuite);
     }
     return $suite;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:56,代码来源:LuaEngineTestBase.php

示例9: enhancePhpunitTest

 protected function enhancePhpunitTest(\PHPUnit_Framework_TestCase $test)
 {
     $className = get_class($test);
     $methodName = $test->getName(false);
     $dependencies = \PHPUnit_Util_Test::getDependencies($className, $methodName);
     $test->setDependencies($dependencies);
     if ($test instanceof TestCaseFormat) {
         $test->getMetadata()->setDependencies($dependencies);
         $test->getMetadata()->setEnv(Annotation::forMethod($test, $methodName)->fetchAll('env'));
     }
 }
开发者ID:foxman209,项目名称:Codeception,代码行数:11,代码来源:Unit.php

示例10: beforeClass

 public function beforeClass(SuiteEvent $e)
 {
     foreach ($e->getSuite()->tests() as $test) {
         /** @var $test \PHPUnit_Framework_Test  * */
         if ($test instanceof \PHPUnit_Framework_TestSuite_DataProvider) {
             $potentialTestClass = strstr($test->getName(), '::', true);
             $this->hooks[$potentialTestClass] = \PHPUnit_Util_Test::getHookMethods($potentialTestClass);
         }
         $testClass = get_class($test);
         $this->hooks[$testClass] = \PHPUnit_Util_Test::getHookMethods($testClass);
     }
     $this->runHooks('beforeClass');
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:13,代码来源:BeforeAfterTest.php

示例11: accept

 /**
  * @return boolean
  */
 public function accept()
 {
     $test = $this->getInnerIterator()->current();
     if ($test instanceof PHPUnit_Framework_TestSuite) {
         return TRUE;
     }
     $tmp = PHPUnit_Util_Test::describe($test, FALSE);
     if ($tmp[0] != '') {
         $name = join('::', $tmp);
     } else {
         $name = $tmp[1];
     }
     return preg_match($this->filter, $name);
 }
开发者ID:ramonornela,项目名称:phpunit,代码行数:17,代码来源:Test.php

示例12: enhancePhpunitTest

 protected function enhancePhpunitTest(\PHPUnit_Framework_TestCase $test)
 {
     $className = get_class($test);
     $methodName = $test->getName(false);
     $dependencies = \PHPUnit_Util_Test::getDependencies($className, $methodName);
     $test->setDependencies($dependencies);
     if ($test instanceof UnitFormat) {
         $feature = $test->getName();
         $feature = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1 \\2', $feature);
         $feature = preg_replace('/([a-z\\d])([A-Z])/', '\\1 \\2', $feature);
         $test->getMetadata()->setFeature(strtolower($feature));
         $test->getMetadata()->setDependencies($dependencies);
         $test->getMetadata()->setEnv(Annotation::forMethod($test, $methodName)->fetchAll('env'));
     }
 }
开发者ID:neronmoon,项目名称:Codeception,代码行数:15,代码来源:Unit.php

示例13: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     parent::endTest($test, $time);
     if ($this->debug) {
         foreach ($this->timeColors as $threshold => $color) {
             if ($time >= $threshold) {
                 $timeColor = $color;
                 break;
             }
         }
         $this->write(' ');
         $this->writeWithColor($timeColor, '[' . number_format($time, 3) . 's]', false);
         $this->write(' ');
         $this->writeWithColor('fg-cyan', \PHPUnit_Util_Test::describe($test), true);
     }
 }
开发者ID:diablomedia,项目名称:phpunit-pretty-printer,代码行数:16,代码来源:PrettyPrinter.php

示例14: codeCoverageEnd

 public function codeCoverageEnd($status, $time)
 {
     $codeCoverage = $this->getTestResultObject()->getCodeCoverage();
     if (!$codeCoverage) {
         return;
     }
     $linesToBeCovered = \PHPUnit_Util_Test::getLinesToBeCovered(get_class($this->testClassInstance), 'test');
     $linesToBeUsed = \PHPUnit_Util_Test::getLinesToBeUsed(get_class($this->testClassInstance), 'test');
     try {
         $codeCoverage->stop(true, $linesToBeCovered, $linesToBeUsed);
     } catch (\PHP_CodeCoverage_Exception $cce) {
         if ($status === \Codeception\Test\Test::STATUS_OK) {
             $this->getTestResultObject()->addError($this, $cce, $time);
         }
     }
 }
开发者ID:foxman209,项目名称:Codeception,代码行数:16,代码来源:CodeCoverage.php

示例15: __construct

 /**
  * @constructor
  * @param string $theClass
  * @param string $name
  */
 public function __construct($theClass = '', $name = '')
 {
     $this->initObjectManager();
     $this->appStateFactory = $this->objectManager->get('Mtf\\App\\State\\StateFactory');
     /** @var $applicationStateIterator \Mtf\Util\Iterator\ApplicationState */
     $applicationStateIterator = $this->objectManager->create('Mtf\\Util\\Iterator\\ApplicationState');
     while ($applicationStateIterator->valid()) {
         $appState = $applicationStateIterator->current();
         $callback = [$this, 'appStateCallback'];
         /** @var $suite \Mtf\TestSuite\TestCase */
         $suite = $this->objectManager->create('Mtf\\TestSuite\\TestCase', ['name' => $appState['name']]);
         $suite->setCallback($callback, $appState);
         $this->addTest($suite, \PHPUnit_Util_Test::getGroups(get_class($suite), $suite->getName()));
         $applicationStateIterator->next();
     }
     parent::__construct('Application State Runner');
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:22,代码来源:AppState.php


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