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


PHP PHPUnit_Util_Class::collectEnd方法代码示例

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


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

示例1: load

 /**
  * @param  string  $suiteClassName
  * @param  string  $suiteClassFile
  * @return ReflectionClass
  * @throws RuntimeException
  */
 public function load($suiteClassName, $suiteClassFile = '')
 {
     $suiteClassName = str_replace('.php', '', $suiteClassName);
     if (empty($suiteClassFile)) {
         $suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
     }
     if (!class_exists($suiteClassName, FALSE)) {
         PHPUnit_Util_Class::collectStart();
         $filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile);
         $loadedClasses = PHPUnit_Util_Class::collectEnd();
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $offset = 0 - strlen($suiteClassName);
         foreach ($loadedClasses as $loadedClass) {
             $class = new ReflectionClass($loadedClass);
             if (substr($loadedClass, $offset) === $suiteClassName && $class->getFileName() == $filename) {
                 $suiteClassName = $loadedClass;
                 break;
             }
         }
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $testCaseClass = 'PHPUnit_Framework_TestCase';
         foreach ($loadedClasses as $loadedClass) {
             $class = new ReflectionClass($loadedClass);
             $classFile = $class->getFileName();
             if ($class->isSubclassOf($testCaseClass) && !$class->isAbstract()) {
                 $suiteClassName = $loadedClass;
                 $testCaseClass = $loadedClass;
                 if ($classFile == realpath($suiteClassFile)) {
                     break;
                 }
             }
             if ($class->hasMethod('suite')) {
                 $method = $class->getMethod('suite');
                 if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
                     $suiteClassName = $loadedClass;
                     if ($classFile == realpath($suiteClassFile)) {
                         break;
                     }
                 }
             }
         }
     }
     if (class_exists($suiteClassName, FALSE)) {
         $class = new ReflectionClass($suiteClassName);
         $filePath = $GLOBALS['base_dir'] . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . $suiteClassFile;
         if ($class->getFileName() == realpath($filePath)) {
             return $class;
         }
     }
     throw new PHPUnit_Framework_Exception(sprintf('Class %s could not be found in %s.', $suiteClassName, $suiteClassFile));
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:59,代码来源:StandardTestSuiteLoader.php

示例2: addTestFile

 /**
  * Wraps both <code>addTest()</code> and <code>addTestSuite</code>
  * as well as the separate import statements for the user's convenience.
  *
  * If the named file cannot be read or there are no new tests that can be
  * added, a <code>PHPUnit_Framework_Warning</code> will be created instead,
  * leaving the current test run untouched.
  *
  * @param  string  $filename
  * @param  boolean $syntaxCheck
  * @param  array   $phptOptions Array with ini settings for the php instance
  *                              run, key being the name if the setting,
  *                              value the ini value.
  * @throws InvalidArgumentException
  * @since  Method available since Release 2.3.0
  * @author Stefano F. Rausch <stefano@rausch-e.net>
  */
 public function addTestFile($filename, $syntaxCheck = FALSE, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     if (file_exists($filename) && substr($filename, -5) == '.phpt') {
         $this->addTest(new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions));
         return;
     }
     PHPUnit_Util_Class::collectStart();
     $filename = PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
     $newClasses = PHPUnit_Util_Class::collectEnd();
     $baseName = str_replace('.php', '', basename($filename));
     foreach ($newClasses as $className) {
         if (substr($className, 0 - strlen($baseName)) == $baseName) {
             $class = new ReflectionClass($className);
             if ($class->getFileName() == $filename) {
                 $newClasses = array($className);
                 break;
             }
         }
     }
     $testsFound = FALSE;
     foreach ($newClasses as $className) {
         $class = new ReflectionClass($className);
         if (!$class->isAbstract()) {
             if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
                 $method = $class->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
                 if ($method->isStatic()) {
                     $this->addTest($method->invoke(NULL, $className));
                     $testsFound = TRUE;
                 }
             } else {
                 if ($class->implementsInterface('PHPUnit_Framework_Test')) {
                     $this->addTestSuite($class);
                     $testsFound = TRUE;
                 }
             }
         }
     }
     $this->numTests = -1;
 }
开发者ID:reflectivedevelopment,项目名称:jfh-lib,代码行数:59,代码来源:TestSuite.php

示例3: addTestFile

 /**
  * Wraps both <code>addTest()</code> and <code>addTestSuite</code>
  * as well as the separate import statements for the user's convenience.
  *
  * If the named file cannot be read or there are no new tests that can be
  * added, a <code>PHPUnit_Framework_Warning</code> will be created instead,
  * leaving the current test run untouched.
  *
  * @param  string  $filename
  * @param  array   $phptOptions Array with ini settings for the php instance
  *                              run, key being the name if the setting,
  *                              value the ini value.
  * @throws InvalidArgumentException
  * @since  Method available since Release 2.3.0
  * @author Stefano F. Rausch <stefano@rausch-e.net>
  */
 public function addTestFile($filename, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     if (file_exists($filename) && substr($filename, -5) == '.phpt') {
         require_once 'PHPUnit/Extensions/PhptTestCase.php';
         $this->addTest(new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions));
         return;
     }
     if (!file_exists($filename)) {
         $includePaths = explode(PATH_SEPARATOR, get_include_path());
         foreach ($includePaths as $includePath) {
             $file = $includePath . DIRECTORY_SEPARATOR . $filename;
             if (file_exists($file)) {
                 $filename = $file;
                 break;
             }
         }
     }
     PHPUnit_Util_Class::collectStart();
     PHPUnit_Util_Fileloader::load($filename);
     $newClasses = PHPUnit_Util_Class::collectEnd();
     $baseName = str_replace('.php', '', basename($filename));
     foreach ($newClasses as $className) {
         if (substr($className, 0 - strlen($baseName)) == $baseName) {
             $newClasses = array($className);
             break;
         }
     }
     $testsFound = FALSE;
     foreach ($newClasses as $className) {
         $class = new ReflectionClass($className);
         if (!$class->isAbstract()) {
             if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
                 $method = $class->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
                 if ($method->isStatic()) {
                     $this->addTest($method->invoke(NULL, $className));
                     $testsFound = TRUE;
                 }
             } else {
                 if ($class->implementsInterface('PHPUnit_Framework_Test')) {
                     $this->addTestSuite($class);
                     $testsFound = TRUE;
                 }
             }
         }
     }
     $this->numTests = -1;
 }
开发者ID:arjenschol,项目名称:phpunit,代码行数:66,代码来源:TestSuite.php

示例4: addTestFile

 /**
  * Wraps both <code>addTest()</code> and <code>addTestSuite</code>
  * as well as the separate import statements for the user's convenience.
  *
  * If the named file cannot be read or there are no new tests that can be
  * added, a <code>PHPUnit_Framework_Warning</code> will be created instead,
  * leaving the current test run untouched.
  *
  * @param  string  $filename
  * @param  boolean $syntaxCheck
  * @param  array   $phptOptions Array with ini settings for the php instance
  *                              run, key being the name if the setting,
  *                              value the ini value.
  * @throws InvalidArgumentException
  * @access public
  * @since  Method available since Release 2.3.0
  * @author Stefano F. Rausch <stefano@rausch-e.net>
  */
 public function addTestFile($filename, $syntaxCheck = TRUE, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw new InvalidArgumentException();
     }
     if (file_exists($filename) && substr($filename, -5) == '.phpt') {
         $this->addTest(new PHPUnit_Extensions_PhptTestCase($filename, $phptOptions));
         return;
     }
     if (!file_exists($filename)) {
         $includePaths = explode(PATH_SEPARATOR, get_include_path());
         foreach ($includePaths as $includePath) {
             $file = $includePath . DIRECTORY_SEPARATOR . $filename;
             if (file_exists($file)) {
                 $filename = $file;
                 break;
             }
         }
     }
     PHPUnit_Util_Class::collectStart();
     PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
     $newClasses = PHPUnit_Util_Class::collectEnd();
     $testsFound = FALSE;
     foreach ($newClasses as $className) {
         $class = new ReflectionClass($className);
         if (!$class->isAbstract()) {
             if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
                 $method = $class->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
                 if ($method->isStatic()) {
                     $this->addTest($method->invoke(NULL, $className));
                     $testsFound = TRUE;
                 }
             } else {
                 if ($class->implementsInterface('PHPUnit_Framework_Test')) {
                     $this->addTestSuite($class);
                     $testsFound = TRUE;
                 }
             }
         }
     }
     if (!$testsFound) {
         $this->addTest(new PHPUnit_Framework_Warning('No tests found in file "' . $filename . '".'));
     }
     $this->numTests = -1;
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:63,代码来源:TestSuite.php

示例5: handleCustomTestSuite

 protected function handleCustomTestSuite()
 {
     $directory = getcwd();
     $packages = $this->options[1];
     if (isset($this->arguments['coverageClover']) || isset($this->arguments['reportDirectory'])) {
         $fillWhitelist = true;
     } else {
         $fillWhitelist = false;
     }
     $this->arguments['test'] = new PHPUnit_Framework_TestSuite();
     $this->arguments['test']->setName('eZ Components');
     if (empty($packages)) {
         $packages = $this->getPackages($directory);
     }
     foreach ($packages as $package) {
         $added = false;
         $slashCount = substr_count($package, DIRECTORY_SEPARATOR);
         if ($this->release == 'trunk' && $slashCount !== 0 || $this->release == 'stable' && $slashCount > 1) {
             if (file_exists($package)) {
                 PHPUnit_Util_Class::collectStart();
                 require_once $package;
                 $class = PHPUnit_Util_Class::collectEnd();
                 if (!empty($class)) {
                     $this->arguments['test']->addTest(call_user_func(array(array_pop($class), 'suite')));
                     $added = true;
                     $package = substr($package, 0, strpos($package, DIRECTORY_SEPARATOR));
                 } else {
                     die("\n Cannot load: {$package}. \n");
                 }
             }
         } else {
             $suite = $this->getTestSuite($directory, $package);
             if (!is_null($suite)) {
                 $this->arguments['test']->addTest($suite);
                 $added = true;
             }
         }
         if ($fillWhitelist && $added) {
             foreach (glob($directory . '/' . $package . '/src/*_autoload.php') as $autoloadFile) {
                 foreach (include $autoloadFile as $className => $fileName) {
                     if (strpos($fileName, 'xmlwritersubstitute.php') === false) {
                         PHPUnit_Util_Filter::addFileToWhitelist($directory . '/' . str_replace($package, $package . '/src', $fileName));
                     }
                 }
             }
         }
     }
     if (isset($this->arguments['colors']) && $this->arguments['colors'] === true) {
         $colors = true;
     } else {
         $colors = false;
     }
     if (isset($this->arguments['debug']) && $this->arguments['debug'] === true) {
         $debug = true;
     } else {
         $debug = false;
     }
     if (isset($this->arguments['verbose']) && $this->arguments['verbose'] === true) {
         $verbose = true;
     } else {
         $verbose = false;
     }
     $this->arguments['printer'] = new ezcTestPrinter(NULL, $verbose, $colors, $debug);
 }
开发者ID:naderman,项目名称:pflow,代码行数:64,代码来源:runner.php

示例6: load

 /**
  * @param  string  $suiteClassName
  * @param  string  $suiteClassFile
  * @param  boolean $syntaxCheck
  * @return ReflectionClass
  * @throws RuntimeException
  */
 public function load($suiteClassName, $suiteClassFile = '', $syntaxCheck = TRUE)
 {
     $suiteClassName = str_replace('.php', '', $suiteClassName);
     if (empty($suiteClassFile)) {
         $suiteClassFile = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $suiteClassName) . '.php';
     }
     if (!class_exists($suiteClassName, FALSE)) {
         if (!file_exists($suiteClassFile)) {
             $includePaths = explode(PATH_SEPARATOR, get_include_path());
             foreach ($includePaths as $includePath) {
                 $file = $includePath . DIRECTORY_SEPARATOR . $suiteClassFile;
                 if (file_exists($file)) {
                     $suiteClassFile = $file;
                     break;
                 }
             }
         }
         PHPUnit_Util_Class::collectStart();
         PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile, $syntaxCheck);
         $loadedClasses = PHPUnit_Util_Class::collectEnd();
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $offset = 0 - strlen($suiteClassName);
         foreach ($loadedClasses as $loadedClass) {
             if (substr($loadedClass, $offset) === $suiteClassName) {
                 $suiteClassName = $loadedClass;
                 break;
             }
         }
     }
     if (!class_exists($suiteClassName, FALSE) && !empty($loadedClasses)) {
         $testCaseClass = 'PHPUnit_Framework_TestCase';
         foreach ($loadedClasses as $loadedClass) {
             $class = new ReflectionClass($loadedClass);
             if ($class->isSubclassOf($testCaseClass)) {
                 $suiteClassName = $loadedClass;
                 $testCaseClass = $loadedClass;
                 if ($class->getFileName() == realpath($suiteClassFile)) {
                     break;
                 }
             }
             if ($class->hasMethod('suite')) {
                 $method = $class->getMethod('suite');
                 if (!$method->isAbstract() && $method->isPublic() && $method->isStatic()) {
                     $suiteClassName = $loadedClass;
                     break;
                 }
             }
         }
     }
     if (class_exists($suiteClassName, FALSE)) {
         $class = new ReflectionClass($suiteClassName);
         if ($class->getFileName() == realpath($suiteClassFile)) {
             return $class;
         }
     }
     throw new RuntimeException(sprintf('Class %s could not be found in %s.', $suiteClassName, $suiteClassFile));
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:65,代码来源:StandardTestSuiteLoader.php

示例7: collectTestsFromFile

 public static function collectTestsFromFile($filename)
 {
     PHPUnit_Util_Class::collectStart();
     PHPUnit_Util_Fileloader::checkAndLoad($filename, FALSE);
     $newClasses = PHPUnit_Util_Class::collectEnd();
     $baseName = str_replace('.php', '', basename($filename));
     foreach ($newClasses as $className) {
         if (substr($className, 0 - strlen($baseName)) == $baseName) {
             $newClasses = array($className);
             break;
         }
     }
     $tests = array();
     // of PHPUnit_Framework_Test
     foreach ($newClasses as $className) {
         $class = new ReflectionClass($className);
         if (!$class->isAbstract()) {
             if ($class->hasMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME)) {
                 $method = $class->getMethod(PHPUnit_Runner_BaseTestRunner::SUITE_METHODNAME);
                 if ($method->isStatic()) {
                     $newTest = $method->invoke(NULL, $className);
                     // of type PHPUnit_Framework_Test
                     $tests[] = $newTest;
                 }
             } else {
                 if ($class->implementsInterface('PHPUnit_Framework_Test')) {
                     $tests[] = new PHPUnit_Framework_TestSuite($class);
                 }
             }
         }
     }
     return $tests;
 }
开发者ID:Aktubius,项目名称:Lesons_SAG,代码行数:33,代码来源:_intellij_phpunit_launcher.php

示例8: guess_class_from_path

 protected function guess_class_from_path($file)
 {
     // Somebody is using just the file name, we need to look inside the file and guess the testcase
     // class name. Let's throw fatal error if there are more testcases in one file.
     PHPUnit_Util_Class::collectStart();
     PHPUnit_Util_Fileloader::checkAndLoad($file);
     $includePathFilename = stream_resolve_include_path($file);
     $loadedClasses = PHPUnit_Util_Class::collectEnd();
     $candidates = array();
     foreach ($loadedClasses as $loadedClass) {
         $class = new ReflectionClass($loadedClass);
         if ($class->isSubclassOf('PHPUnit_Framework_TestCase') and !$class->isAbstract()) {
             if (realpath($includePathFilename) === realpath($class->getFileName())) {
                 $candidates[] = $loadedClass;
             }
         }
     }
     if (count($candidates) == 0) {
         throw new PHPUnit_Framework_Exception(sprintf("File '%s' does not contain any test cases.", $file));
     }
     if (count($candidates) > 1) {
         throw new PHPUnit_Framework_Exception(sprintf("File '%s' contains multiple test cases: " . implode(', ', $candidates), $file));
     }
     $classname = reset($candidates);
     return new ReflectionClass($classname);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:26,代码来源:autoloader.php


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