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


PHP PHPUnit_Framework_TestSuite::createTest方法代码示例

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


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

示例1: createTestFromPhpUnitMethod

 protected function createTestFromPhpUnitMethod(\ReflectionClass $class, \ReflectionMethod $method)
 {
     if (!\PHPUnit_Framework_TestSuite::isTestMethod($method)) {
         return;
     }
     $test = \PHPUnit_Framework_TestSuite::createTest($class, $method->name);
     if ($test instanceof \PHPUnit_Framework_TestSuite_DataProvider) {
         foreach ($test->tests() as $t) {
             $this->enhancePhpunitTest($t);
         }
         return $test;
     }
     $this->enhancePhpunitTest($test);
     return $test;
 }
开发者ID:neronmoon,项目名称:Codeception,代码行数:15,代码来源:Unit.php

示例2: createTestFromPhpUnitMethod

 protected function createTestFromPhpUnitMethod(\ReflectionClass $class, \ReflectionMethod $method)
 {
     if (!\PHPUnit_Framework_TestSuite::isTestMethod($method) and strpos($method->name, 'should') !== 0) {
         return;
     }
     $test = \PHPUnit_Framework_TestSuite::createTest($class, $method->name);
     if ($test instanceof TestCase\Test) {
         $test->setBootstrap($this->settings['bootstrap']);
         $test->setDispatcher($this->dispatcher);
         $test->setGuyClass($this->settings['class_name']);
         $groups = \PHPUnit_Util_Test::getGroups($class->name, $method->name);
         $test->getScenario()->groups($groups);
     } else {
         if ($this->settings['bootstrap']) {
             require_once $this->settings['bootstrap'];
         }
     }
     return $test;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:19,代码来源:SuiteManager.php

示例3: main


//.........这里部分代码省略.........
         if ($check == "d") {
             // if run directory
             // in remote case we put this script in the test directory
             $suiteDirName = $isLocal ? $_SERVER['argv'][$startPos + 1] : dirname(__FILE__);
             if (is_dir($suiteDirName) && !is_file($suiteDirName . '.php')) {
                 $testCollector = new PHPUnit_Runner_IncludePathTestCollector(array($suiteDirName));
                 // $test = new PHPUnit_Framework_TestSuite($suiteDirName);
                 $filenames = $testCollector->collectTests();
                 $number = 0;
                 $alltests = array();
                 foreach ($filenames as $filename) {
                     $tests = self::collectTestsFromFile($filename);
                     foreach ($tests as $currenttest) {
                         $number += sizeof($currenttest);
                         $alltests[] = $currenttest;
                         $alltests[] = $filename;
                     }
                 }
                 if ($canCountTest) {
                     print traceCommand("testCount", "count", (string) $number);
                 }
                 for ($i = 0; $i < count($alltests); $i += 2) {
                     self::runTest($alltests[$i], $alltests[$i + 1], $arguments);
                 }
                 return;
             }
         } else {
             if ($check == 'f') {
                 // if run all in file
                 $filename = $isLocal ? $_SERVER['argv'][$startPos + 1] : $_GET["file"];
                 $tests = self::collectTestsFromFile($filename);
                 $test = new PHPUnit_Framework_TestSuite();
                 $number = 0;
                 foreach ($tests as $currenttest) {
                     if ($tests) {
                         $test->addTest($currenttest);
                         $number += sizeof($currenttest);
                     }
                 }
                 if ($canCountTest) {
                     print traceCommand("testCount", "count", $number);
                 }
                 foreach ($tests as $currentTest) {
                     self::runTest($currentTest, $filename, $arguments);
                 }
                 return;
             } else {
                 if ($check == 'm') {
                     $suiteMethodName = $isLocal ? $_SERVER['argv'][$startPos + 1] : $_GET["method"];
                     $suiteClassName = $isLocal ? $_SERVER['argv'][$startPos + 2] : $_GET["class"];
                     $suiteClassFile = $isLocal ? $_SERVER['argv'][$startPos + 3] : $_GET["file"];
                     try {
                         $testClass = new PHPUnit_Runner_StandardTestSuiteLoader();
                         $testClass = $testClass->load($suiteClassName, $suiteClassFile, FALSE);
                     } catch (Exception $e) {
                         myExceptionHandler($e);
                         return;
                     }
                     try {
                         // if class is a suite
                         $suiteMethod = $testClass->getMethod($suiteMethodName);
                         if ($suiteMethodName == 'suite') {
                             if ($suiteMethod->isAbstract() || !$suiteMethod->isPublic() || !$suiteMethod->isStatic()) {
                                 return;
                             }
                             try {
                                 $test = $suiteMethod->invoke(NULL, $testClass->getName());
                                 $test->setName($suiteClassName);
                                 if ($canCountTest) {
                                     print traceCommand("testCount", "count", (string) sizeof($test));
                                 }
                                 self::runTest($test, $suiteClassFile, $arguments);
                             } catch (ReflectionException $e) {
                                 myExceptionHandler($e);
                                 return;
                             }
                         } else {
                             $test = PHPUnit_Framework_TestSuite::createTest($testClass, $suiteMethodName);
                             $testSuite = new PHPUnit_Framework_TestSuite();
                             $testSuite->addTest($test);
                             $testSuite->setName($suiteClassName);
                             if ($canCountTest) {
                                 print traceCommand("testCount", "count", (string) sizeof($test));
                             }
                             self::runTest($testSuite, $suiteClassFile, $arguments);
                         }
                     } catch (ReflectionException $e) {
                         myExceptionHandler($e);
                         return;
                     }
                 } else {
                     if ($check == 'x') {
                         $testSuite = $configuration->getTestSuiteConfiguration();
                         self::runTest($testSuite, "", $arguments);
                     }
                 }
             }
         }
     }
 }
开发者ID:Aktubius,项目名称:Lesons_SAG,代码行数:101,代码来源:_intellij_phpunit_launcher.php

示例4: suite

 /**
  * @param  string $className
  * @return PHPUnit_Framework_TestSuite
  */
 public static function suite($className)
 {
     $suite = new PHPUnit_Extensions_SeleniumTestSuite();
     $suite->setName($className);
     $class = new ReflectionClass($className);
     $classGroups = PHPUnit_Util_Test::getGroups($className);
     $staticProperties = $class->getStaticProperties();
     // Create tests from Selenese/HTML files.
     if (isset($staticProperties['seleneseDirectory']) && is_dir($staticProperties['seleneseDirectory'])) {
         $files = array_merge(self::getSeleneseFiles($staticProperties['seleneseDirectory'], '.htm'), self::getSeleneseFiles($staticProperties['seleneseDirectory'], '.html'));
         // Create tests from Selenese/HTML files for multiple browsers.
         if (!empty($staticProperties['browsers'])) {
             foreach ($staticProperties['browsers'] as $browser) {
                 $browserSuite = new PHPUnit_Framework_TestSuite();
                 $browserSuite->setName($className . ': ' . $browser['name']);
                 foreach ($files as $file) {
                     self::addConfiguredTestTo($browserSuite, new $className($file, array(), '', $browser), $classGroups);
                 }
                 $suite->addTest($browserSuite);
             }
         } else {
             foreach ($files as $file) {
                 self::addConfiguredTestTo($suite, new $className($file), $classGroups);
             }
         }
     }
     // Create tests from test methods for multiple browsers.
     if (!empty($staticProperties['browsers'])) {
         foreach ($staticProperties['browsers'] as $browser) {
             $browserSuite = new PHPUnit_Framework_TestSuite();
             $browserSuite->setName($className . ': ' . $browser['name']);
             foreach ($class->getMethods() as $method) {
                 if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                     $name = $method->getName();
                     $test = PHPUnit_Framework_TestSuite::createTest($class, $name);
                     if ($test instanceof PHPUnit_Framework_TestCase) {
                         $test->setupSpecificBrowser($browser);
                         $groups = PHPUnit_Util_Test::getGroups($className, $name);
                         self::addConfiguredTestTo($browserSuite, $test, $groups);
                     } else {
                         $browserSuite->addTest($test);
                     }
                 }
             }
             $suite->addTest($browserSuite);
         }
     } else {
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $test = PHPUnit_Framework_TestSuite::createTest($class, $name);
                 if ($test instanceof PHPUnit_Framework_TestCase) {
                     $groups = PHPUnit_Util_Test::getGroups($className, $name);
                     self::addConfiguredTestTo($suite, $test, $groups);
                 } else {
                     $suite->addTest($test);
                 }
             }
         }
     }
     return $suite;
 }
开发者ID:robinhood-zz,项目名称:phpunit-selenium,代码行数:66,代码来源:SeleniumTestCase.php

示例5: createTestFromPhpUnitMethod

 /**
  * Creates test from PHPUnit method.
  *
  * @since 1.0.0
  *
  * @access protected
  * @param \ReflectionClass $class The class object.
  * @param \ReflectionMethod $method The method object.
  * @return \PHPUnit_Framework_Test The test object.
  */
 protected function createTestFromPhpUnitMethod(\ReflectionClass $class, \ReflectionMethod $method)
 {
     if (!\PHPUnit_Framework_TestSuite::isTestMethod($method)) {
         return;
     }
     $test = \PHPUnit_Framework_TestSuite::createTest($class, $method->name);
     if ($test instanceof \PHPUnit_Framework_TestSuite_DataProvider) {
         foreach ($test->tests() as $t) {
             $this->enhancePhpunitTest($t);
         }
     } else {
         $this->enhancePhpunitTest($test);
     }
     $test->setBackupGlobals(false);
     $test->setBackupStaticAttributes(false);
     $test->setRunTestInSeparateProcess(false);
     $test->setInIsolation(false);
     $test->setPreserveGlobalState(false);
     return $test;
 }
开发者ID:gedex,项目名称:wp-codeception,代码行数:30,代码来源:TestLoader.php


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