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


PHP PHPUnit_Util_Test::getProvidedData方法代码示例

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


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

示例1: 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

示例2: createTest

 /**
  * @param  ReflectionClass             $theClass
  * @param  string                      $name
  * @return PHPUnit_Framework_Test
  * @throws PHPUnit_Framework_Exception
  */
 public static function createTest(ReflectionClass $theClass, $name)
 {
     $className = $theClass->getName();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     $backupSettings = PHPUnit_Util_Test::getBackupSettings($className, $name);
     $preserveGlobalState = PHPUnit_Util_Test::getPreserveGlobalStateSettings($className, $name);
     $runTestInSeparateProcess = PHPUnit_Util_Test::getProcessIsolationSettings($className, $name);
     $constructor = $theClass->getConstructor();
     if ($constructor !== null) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             try {
                 $data = PHPUnit_Util_Test::getProvidedData($className, $name);
             } catch (PHPUnit_Framework_IncompleteTestError $e) {
                 $message = sprintf('Test for %s::%s marked incomplete by data provider', $className, $name);
                 $_message = $e->getMessage();
                 if (!empty($_message)) {
                     $message .= "\n" . $_message;
                 }
                 $data = self::incompleteTest($className, $name, $message);
             } catch (PHPUnit_Framework_SkippedTestError $e) {
                 $message = sprintf('Test for %s::%s skipped by data provider', $className, $name);
                 $_message = $e->getMessage();
                 if (!empty($_message)) {
                     $message .= "\n" . $_message;
                 }
                 $data = self::skipTest($className, $name, $message);
             } catch (Throwable $_t) {
                 $t = $_t;
             } catch (Exception $_t) {
                 $t = $_t;
             }
             if (isset($t)) {
                 $message = sprintf('The data provider specified for %s::%s is invalid.', $className, $name);
                 $_message = $t->getMessage();
                 if (!empty($_message)) {
                     $message .= "\n" . $_message;
                 }
                 $data = self::warning($message);
             }
             // Test method with @dataProvider.
             if (isset($data)) {
                 $test = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                 if (empty($data)) {
                     $data = self::warning(sprintf('No tests found in suite "%s".', $test->getName()));
                 }
                 $groups = PHPUnit_Util_Test::getGroups($className, $name);
                 if ($data instanceof PHPUnit_Framework_Warning || $data instanceof PHPUnit_Framework_SkippedTestCase || $data instanceof PHPUnit_Framework_IncompleteTestCase) {
                     $test->addTest($data, $groups);
                 } else {
                     foreach ($data as $_dataName => $_data) {
                         $_test = new $className($name, $_data, $_dataName);
                         if ($runTestInSeparateProcess) {
                             $_test->setRunTestInSeparateProcess(true);
                             if ($preserveGlobalState !== null) {
                                 $_test->setPreserveGlobalState($preserveGlobalState);
                             }
                         }
                         if ($backupSettings['backupGlobals'] !== null) {
                             $_test->setBackupGlobals($backupSettings['backupGlobals']);
                         }
                         if ($backupSettings['backupStaticAttributes'] !== null) {
                             $_test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
                         }
                         $test->addTest($_test, $groups);
                     }
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if (!isset($test)) {
         throw new PHPUnit_Framework_Exception('No valid test provided.');
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if ($runTestInSeparateProcess) {
             $test->setRunTestInSeparateProcess(true);
             if ($preserveGlobalState !== null) {
                 $test->setPreserveGlobalState($preserveGlobalState);
             }
         }
         if ($backupSettings['backupGlobals'] !== null) {
             $test->setBackupGlobals($backupSettings['backupGlobals']);
         }
         if ($backupSettings['backupStaticAttributes'] !== null) {
             $test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
         }
//.........这里部分代码省略.........
开发者ID:441420776,项目名称:phpunit,代码行数:101,代码来源:TestSuite.php

示例3: suite

 /**
  * @param  string $className
  * @return PHPUnit_Framework_TestSuite
  */
 public static function suite($className)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $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) {
                     $browserSuite->addTest(new $className($file, array(), '', $browser), $classGroups);
                 }
                 $suite->addTest($browserSuite);
             }
         } else {
             foreach ($files as $file) {
                 $suite->addTest(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();
                     $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                     $groups = PHPUnit_Util_Test::getGroups($className, $name);
                     // Test method with @dataProvider.
                     if (is_array($data) || $data instanceof Iterator) {
                         $dataSuite = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                         foreach ($data as $_dataName => $_data) {
                             $dataSuite->addTest(new $className($name, $_data, $_dataName, $browser), $groups);
                         }
                         $browserSuite->addTest($dataSuite);
                     } else {
                         if ($data === FALSE) {
                             $browserSuite->addTest(new PHPUnit_Framework_Warning(sprintf('The data provider specified for %s::%s is invalid.', $className, $name)));
                         } else {
                             $browserSuite->addTest(new $className($name, array(), '', $browser), $groups);
                         }
                     }
                 }
             }
             $suite->addTest($browserSuite);
         }
     } else {
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                 $groups = PHPUnit_Util_Test::getGroups($className, $name);
                 // Test method with @dataProvider.
                 if (is_array($data) || $data instanceof Iterator) {
                     $dataSuite = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                     foreach ($data as $_dataName => $_data) {
                         $dataSuite->addTest(new $className($name, $_data, $_dataName), $groups);
                     }
                     $suite->addTest($dataSuite);
                 } else {
                     if ($data === FALSE) {
                         $suite->addTest(new PHPUnit_Framework_Warning(sprintf('The data provider specified for %s::%s is invalid.', $className, $name)));
                     } else {
                         $suite->addTest(new $className($name), $groups);
                     }
                 }
             }
         }
     }
     return $suite;
 }
开发者ID:ninodafonte,项目名称:SIFO,代码行数:83,代码来源:SeleniumTestCase.php

示例4: createTest

 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @param  array           $classGroups
  * @return PHPUnit_Framework_Test
  */
 public static function createTest(ReflectionClass $theClass, $name, array $classGroups = array())
 {
     $className = $theClass->getName();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     $classDocComment = $theClass->getDocComment();
     $method = new ReflectionMethod($className, $name);
     $methodDocComment = $method->getDocComment();
     $backupSettings = PHPUnit_Util_Test::getBackupSettings($className, $name);
     $preserveGlobalState = PHPUnit_Util_Test::getPreserveGlobalStateSettings($className, $name);
     $runTestInSeparateProcess = PHPUnit_Util_Test::getProcessIsolationSettings($className, $name);
     $constructor = $theClass->getConstructor();
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name);
             $groups = PHPUnit_Util_Test::getGroups($className, $name);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                 foreach ($data as $_dataName => $_data) {
                     $_test = new $className($name, $_data, $_dataName);
                     if ($runTestInSeparateProcess) {
                         $_test->setRunTestInSeparateProcess(TRUE);
                         if ($preserveGlobalState !== NULL) {
                             $_test->setPreserveGlobalState($preserveGlobalState);
                         }
                     }
                     if ($backupSettings['backupGlobals'] !== NULL) {
                         $_test->setBackupGlobals($backupSettings['backupGlobals']);
                     }
                     if ($backupSettings['backupStaticAttributes'] !== NULL) {
                         $_test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
                     }
                     $test->addTest($_test, $groups);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if ($runTestInSeparateProcess) {
             $test->setRunTestInSeparateProcess(TRUE);
             if ($preserveGlobalState !== NULL) {
                 $test->setPreserveGlobalState($preserveGlobalState);
             }
         }
         if ($backupSettings['backupGlobals'] !== NULL) {
             $test->setBackupGlobals($backupSettings['backupGlobals']);
         }
         if ($backupSettings['backupStaticAttributes'] !== NULL) {
             $test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
         }
     }
     return $test;
 }
开发者ID:arjenschol,项目名称:phpunit,代码行数:67,代码来源:TestSuite.php

示例5: createTest

 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @return PHPUnit_Framework_Test
  * @access public
  * @static
  */
 public static function createTest(ReflectionClass $theClass, $name)
 {
     $className = $theClass->getName();
     $method = new ReflectionMethod($className, $name);
     $docComment = $method->getDocComment();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     // @expectedException ExceptionClass              on TestCase::testMethod()
     // @expectedException ExceptionClass message      on TestCase::testMethod()
     // @expectedException ExceptionClass message code on TestCase::testMethod()
     if (preg_match('(@expectedException\\s+([:.\\w]+)(?:[\\t ]+(\\S*))?(?:[\\t ]+(\\S*))?[\\t ]*$)m', $docComment, $matches)) {
         $expectedException = $matches[1];
         if (isset($matches[2])) {
             $expectedExceptionMessage = trim($matches[2]);
         } else {
             $expectedExceptionMessage = '';
         }
         if (isset($matches[3])) {
             $expectedExceptionCode = (int) $matches[3];
         } else {
             $expectedExceptionCode = 0;
         }
     }
     $constructor = $theClass->getConstructor();
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                 foreach ($data as $_dataName => $_data) {
                     $_test = new $className($name, $_data, $_dataName);
                     if ($_test instanceof PHPUnit_Framework_TestCase && isset($expectedException)) {
                         $_test->setExpectedException($expectedException, $expectedExceptionMessage, $expectedExceptionCode);
                     }
                     $test->addTest($_test);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if (isset($expectedException)) {
             $test->setExpectedException($expectedException, $expectedExceptionMessage, $expectedExceptionCode);
         }
     }
     return $test;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:61,代码来源:TestSuite.php

示例6: createTest

 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @param  array           $classGroups
  * @return PHPUnit_Framework_Test
  */
 public static function createTest(ReflectionClass $theClass, $name, array $classGroups = array())
 {
     $className = $theClass->getName();
     $method = new ReflectionMethod($className, $name);
     $methodDocComment = $method->getDocComment();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     $constructor = $theClass->getConstructor();
     $expectedException = PHPUnit_Util_Test::getExpectedException($methodDocComment);
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name, $methodDocComment);
             $groups = PHPUnit_Util_Test::getGroups($methodDocComment, $classGroups);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                 foreach ($data as $_dataName => $_data) {
                     $_test = new $className($name, $_data, $_dataName);
                     if ($_test instanceof PHPUnit_Framework_TestCase && isset($expectedException)) {
                         $_test->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
                     }
                     $test->addTest($_test, $groups);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if (isset($expectedException)) {
             $test->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
         }
     }
     return $test;
 }
开发者ID:cjmi,项目名称:miniblog,代码行数:46,代码来源:TestSuite.php

示例7: suite

 /**
  * @param  string $className
  * @return PHPUnit_Framework_TestSuite
  * @access public
  */
 public static function suite($className)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName($className);
     $class = new ReflectionClass($className);
     $classGroups = PHPUnit_Util_Test::getGroups($class);
     $staticProperties = $class->getStaticProperties();
     // Create tests from Selenese/HTML files.
     if (isset($staticProperties['seleneseDirectory']) && is_dir($staticProperties['seleneseDirectory'])) {
         $files = new PHPUnit_Util_FilterIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($staticProperties['seleneseDirectory'])), '.htm');
         // Create tests from Selenese/HTML files for multiple browsers.
         if (isset($staticProperties['browsers'])) {
             foreach ($staticProperties['browsers'] as $browser) {
                 $browserSuite = new PHPUnit_Framework_TestSuite();
                 $browserSuite->setName($className . ': ' . $browser['name']);
                 foreach ($files as $file) {
                     $browserSuite->addTest(new $className((string) $file, array(), $browser));
                 }
                 $suite->addTest($browserSuite, $classGroups);
             }
         } else {
             foreach ($files as $file) {
                 $suite->addTest(new $className((string) $file), $classGroups);
             }
         }
     }
     // Create tests from test methods for multiple browsers.
     if (isset($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();
                     $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                     $groups = PHPUnit_Util_Test::getGroups($method, $classGroups);
                     // Test method with @dataProvider.
                     if (is_array($data) || $data instanceof Iterator) {
                         $dataSuite = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                         foreach ($data as $_data) {
                             $dataSuite->addTest(new $className($name, $_data, $browser), $groups);
                         }
                         $browserSuite->addTest($dataSuite);
                     } else {
                         $browserSuite->addTest(new $className($name, array(), $browser), $groups);
                     }
                 }
             }
             $suite->addTest($browserSuite);
         }
     } else {
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                 $groups = PHPUnit_Util_Test::getGroups($method, $classGroups);
                 // Test method with @dataProvider.
                 if (is_array($data) || $data instanceof Iterator) {
                     $dataSuite = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                     foreach ($data as $_data) {
                         $dataSuite->addTest(new $className($name, $_data), $groups);
                     }
                     $suite->addTest($dataSuite);
                 } else {
                     $suite->addTest(new $className($name), $groups);
                 }
             }
         }
     }
     return $suite;
 }
开发者ID:humansky,项目名称:qframe,代码行数:76,代码来源:SeleniumTestCase.php

示例8: setLastTestNameInClass

 /**
  * Define name of last testcase in test class
  */
 private function setLastTestNameInClass()
 {
     $testMethods = array();
     $class = new ReflectionClass(self::$_testClass);
     foreach ($class->getMethods() as $method) {
         if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
             $testMethods[] = $method->getName();
         }
     }
     $testName = end($testMethods);
     $data = PHPUnit_Util_Test::getProvidedData(self::$_testClass, $testName);
     if ($data) {
         $testName .= sprintf(' with data set #%d', count($data) - 1);
     }
     self::$_lastTestNameInClass = $testName;
 }
开发者ID:venkateshcontus,项目名称:taf,代码行数:19,代码来源:TestCase.php

示例9: suite

 /**
  * @param  string $className
  * @return PHPUnit_Framework_TestSuite
  */
 public static function suite($className)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setName($className);
     $class = new ReflectionClass($className);
     $classGroups = PHPUnit_Util_Test::getGroups($className);
     $staticProperties = $class->getStaticProperties();
     if (defined('XLITE_TEST_BROWSERS_LIST')) {
         $staticProperties['browsers'] = unserialize(XLITE_TEST_BROWSERS_LIST);
     }
     // Leave only one browser in deployment mode
     if (defined('DEPLOYMENT_TEST') && !empty($staticProperties['browsers'])) {
         $_browsers = array();
         foreach ($staticProperties['browsers'] as $key => $value) {
             $_browsers[$key] = $value;
             break;
         }
         $staticProperties['browsers'] = $_browsers;
     }
     // 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) {
                     $browserSuite->addTest(new $className($file, array(), '', $browser), $classGroups);
                 }
                 $suite->addTest($browserSuite);
             }
         } else {
             foreach ($files as $file) {
                 $suite->addTest(new $className($file), $classGroups);
             }
         }
     }
     // Create tests from test methods for multiple browsers.
     if (!empty($staticProperties['browsers'])) {
         foreach ($staticProperties['browsers'] as $browser) {
             if (defined('NO_RESTORE')) {
                 $browserSuite = new PHPUnit_Framework_TestSuite();
             } else {
                 $browserSuite = new XLite_Tests_TestSuite();
             }
             $browserSuite->setName($className . ': ' . $browser['name']);
             foreach ($class->getMethods() as $method) {
                 if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                     $name = $method->getName();
                     $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                     $groups = PHPUnit_Util_Test::getGroups($className, $name);
                     // Test method with @dataProvider.
                     if (is_array($data) || $data instanceof Iterator) {
                         $dataSuite = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                         foreach ($data as $_dataName => $_data) {
                             $dataSuite->addTest(new $className($name, $_data, $_dataName, $browser), $groups);
                         }
                         $browserSuite->addTest($dataSuite);
                     } else {
                         if ($data === FALSE) {
                             $browserSuite->addTest(new PHPUnit_Framework_Warning(sprintf('The data provider specified for %s::%s is invalid.', $className, $name)));
                         } else {
                             $browserSuite->addTest(new $className($name, array(), '', $browser), $groups);
                         }
                     }
                 }
             }
             $suite->addTest($browserSuite);
         }
     } else {
         foreach ($class->getMethods() as $method) {
             if (PHPUnit_Framework_TestSuite::isPublicTestMethod($method)) {
                 $name = $method->getName();
                 $data = PHPUnit_Util_Test::getProvidedData($className, $name);
                 $groups = PHPUnit_Util_Test::getGroups($className, $name);
                 // Test method with @dataProvider.
                 if (is_array($data) || $data instanceof Iterator) {
                     $dataSuite = new PHPUnit_Framework_TestSuite_DataProvider($className . '::' . $name);
                     foreach ($data as $_dataName => $_data) {
                         $dataSuite->addTest(new $className($name, $_data, $_dataName), $groups);
                     }
                     $suite->addTest($dataSuite);
                 } else {
                     if ($data === FALSE) {
                         $suite->addTest(new PHPUnit_Framework_Warning(sprintf('The data provider specified for %s::%s is invalid.', $className, $name)));
                     } else {
                         $suite->addTest(new $className($name), $groups);
                     }
                 }
             }
         }
     }
     return $suite;
 }
开发者ID:kingsj,项目名称:core,代码行数:99,代码来源:SeleniumTestCase.php

示例10: createTest

 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @return PHPUnit_Framework_Test
  * @access public
  * @static
  */
 public static function createTest(ReflectionClass $theClass, $name)
 {
     $className = $theClass->getName();
     $method = new ReflectionMethod($className, $name);
     $docComment = $method->getDocComment();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     if (preg_match('/@expectedException[\\s]+([:\\.\\w]+)/', $docComment, $matches)) {
         $expectedException = $matches[1];
     }
     $constructor = $theClass->getConstructor();
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                 foreach ($data as $_data) {
                     $_test = new $className($name, $_data);
                     if ($_test instanceof PHPUnit_Framework_TestCase && isset($expectedException)) {
                         $_test->setExpectedException($expectedException);
                     }
                     $test->addTest($_test);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if (isset($expectedException)) {
             $test->setExpectedException($expectedException);
         }
     }
     return $test;
 }
开发者ID:humansky,项目名称:qframe,代码行数:48,代码来源:TestSuite.php

示例11: testMultipleDataProviders

 /**
  * Check if all data providers are being merged.
  */
 public function testMultipleDataProviders()
 {
     $dataSets = PHPUnit_Util_Test::getProvidedData('MultipleDataProviderTest', 'testOne');
     $this->assertEquals(9, count($dataSets));
     $aCount = 0;
     $bCount = 0;
     $cCount = 0;
     for ($i = 0; $i < 9; $i++) {
         $aCount += $dataSets[$i][0] != null ? 1 : 0;
         $bCount += $dataSets[$i][1] != null ? 1 : 0;
         $cCount += $dataSets[$i][2] != null ? 1 : 0;
     }
     $this->assertEquals(3, $aCount);
     $this->assertEquals(3, $bCount);
     $this->assertEquals(3, $cCount);
 }
开发者ID:sebastianbergmann,项目名称:phpunit,代码行数:19,代码来源:TestTest.php

示例12: createTest

 /**
  * Custom implementation of native PHPUnit_Framework_TestSuite::createTest method
  *  - Test Case class should be instantiated with MTF Object Manager
  *  - Data Provider Test Suite should be instantiated with MTF Object Manager
  *
  * @param \ReflectionClass $theClass
  * @param string $name
  * @param array $arguments
  * @return \PHPUnit_Framework_Test
  * @throws \PHPUnit_Framework_Exception
  */
 public static function createTest(\ReflectionClass $theClass, $name, array $arguments = [])
 {
     $objectManager = \Mtf\ObjectManager::getInstance();
     $class = $theClass->getName();
     $arguments['name'] = $name;
     $backupSettings = \PHPUnit_Util_Test::getBackupSettings($class, $name);
     $preserveGlobalState = \PHPUnit_Util_Test::getPreserveGlobalStateSettings($class, $name);
     $runTestInSeparateProcess = \PHPUnit_Util_Test::getProcessIsolationSettings($class, $name);
     try {
         $data = \PHPUnit_Util_Test::getProvidedData($class, $name);
     } catch (\Exception $e) {
         /** @var EventManager $eventManager */
         $eventManager = $objectManager->get('Mtf\\System\\Event\\Event');
         $eventManager->dispatchEvent(['exception'], [$e]);
         $message = sprintf('The data provider specified for %s::%s is invalid.', $class, $name);
         $_message = $e->getMessage();
         if (!empty($_message)) {
             $message .= "\n" . $_message;
         }
         $data = new \PHPUnit_Framework_Warning($message);
     }
     // Test method with @dataProvider.
     if (isset($data)) {
         $test = $objectManager->create('Mtf\\TestSuite\\InjectableDataProvider', ['class' => $class . '::' . $name]);
         if (empty($data)) {
             $data = new \PHPUnit_Framework_Warning(sprintf('No tests found in suite "%s".', $test->getName()));
         }
         $groups = \PHPUnit_Util_Test::getGroups($class, $name);
         if ($data instanceof \PHPUnit_Framework_Warning) {
             $test->addTest($data, $groups);
         } else {
             foreach ($data as $_dataName => $_data) {
                 $_arguments = $arguments;
                 $_arguments['data'] = $_data;
                 $_arguments['dataName'] = $_dataName;
                 $_test = $objectManager->create($class, $_arguments);
                 if ($runTestInSeparateProcess) {
                     $_test->setRunTestInSeparateProcess(true);
                     if ($preserveGlobalState !== null) {
                         $_test->setPreserveGlobalState($preserveGlobalState);
                     }
                 }
                 if ($backupSettings['backupGlobals'] !== null) {
                     $_test->setBackupGlobals($backupSettings['backupGlobals']);
                 }
                 if ($backupSettings['backupStaticAttributes'] !== null) {
                     $_test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
                 }
                 $test->addTest($_test, $groups);
             }
         }
     } else {
         $test = $objectManager->create($class, $arguments);
     }
     if (!isset($test)) {
         throw new \PHPUnit_Framework_Exception('No valid test provided.');
     }
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if ($runTestInSeparateProcess) {
             $test->setRunTestInSeparateProcess(true);
             if ($preserveGlobalState !== null) {
                 $test->setPreserveGlobalState($preserveGlobalState);
             }
         }
         if ($backupSettings['backupGlobals'] !== null) {
             $test->setBackupGlobals($backupSettings['backupGlobals']);
         }
         if ($backupSettings['backupStaticAttributes'] !== null) {
             $test->setBackupStaticAttributes($backupSettings['backupStaticAttributes']);
         }
     }
     return $test;
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:85,代码来源:InjectableMethod.php


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