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


PHP PHPUnit_Util_Fileloader类代码示例

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


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

示例1: run

 /**
  * Run the runner.
  *
  * This will get a singleton instance of the class and configure
  * it according to the given configuration and any $_REQUEST
  * overriding parameters.
  *
  * It will configure it to use a {@link PHPUnit_Html_Printer} object
  * as the default output printer.
  *
  * @param   array       $arguments  configuration
  * @return  void
  */
 public static function run($arguments = array())
 {
     $_arguments = array('tpldir' => null, 'test' => null, 'testFile' => null, 'coverageClover' => null, 'coverageHtml' => null, 'filter' => null, 'groups' => null, 'excludeGroups' => null, 'processInsolation' => null, 'syntaxCheck' => false, 'stopOnError' => false, 'stopOnFailure' => false, 'stopOnIncomplete' => false, 'stopOnSkipped' => false, 'noGlobalsBackup' => true, 'staticBackup' => true, 'syntaxCheck' => false, 'bootstrap' => null, 'configuration' => null, 'noConfiguration' => false, 'strict' => false);
     $printer = new PHPUnit_Html_Printer($arguments['tpldir']);
     try {
         $arguments = $arguments ? array_merge($_arguments, array_intersect_key($arguments, $_arguments)) : $_arguments;
         $arguments['backupGlobals'] = !$arguments['noGlobalsBackup'];
         unset($arguments['noGlobalsBackup']);
         $arguments['backupStaticAttributes'] = !$arguments['staticBackup'];
         unset($arguments['staticBackup']);
         $arguments['useDefaultConfiguration'] = !$arguments['noConfiguration'];
         unset($arguments['noConfiguration']);
         if (isset($arguments['coverageHtml'])) {
             $arguments['reportDirectory'] = $arguments['coverageHtml'];
             unset($arguments['coverageHtml']);
         }
         if (!isset($arguments['test']) && !isset($arguments['testFile'])) {
             $arguments['test'] = getcwd();
         }
         $arguments['printer'] = $printer;
         $arguments['listeners'] = array(new PHPUnit_Util_DeprecatedFeature_Logger());
         if ($arguments['bootstrap']) {
             PHPUnit_Util_Fileloader::checkAndLoad($arguments['bootstrap'], $arguments['syntaxCheck']);
         }
         $runner = new PHPUnit_Html_TestRunner();
         $suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
         unset($arguments['test']);
         unset($arguments['testFile']);
         $result = $runner->doRun($suite, $arguments);
         $arguments['printer']->printResult($result);
     } catch (Exception $e) {
         $printer->printAborted($e);
     }
 }
开发者ID:phpgit,项目名称:PHPUnit_Html,代码行数:47,代码来源:PHPUnit_Html_TestRunner.php

示例2: handleBootstrap

 /**
  * Loads a bootstrap file.
  *
  * @param  string  $filename
  * @param  boolean $syntaxCheck
  * @see PHPUnit_TextUI_Command::handleBootstrap()
  * @since Method available since Release 2.16.0
  */
 protected function handleBootstrap($filename, $syntaxCheck = false)
 {
     try {
         PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
     } catch (RuntimeException $e) {
         PHPUnit_TextUI_TestRunner::showError($e->getMessage());
     }
 }
开发者ID:nojimage,项目名称:stagehand-testrunner,代码行数:16,代码来源:PHPUnitPreparator.php

示例3: main

 public static function main($configFile)
 {
     $arguments = array('listGroups' => FALSE, 'loader' => NULL, 'useDefaultConfiguration' => TRUE, 'configuration' => $configFile);
     $configuration = PHPUnit_Util_Configuration::getInstance($configFile);
     $configuration->handlePHPConfiguration();
     $phpunit = $configuration->getPHPUnitConfiguration();
     if (isset($phpunit['bootstrap'])) {
         PHPUnit_Util_Fileloader::load($phpunit['bootstrap']);
     }
     $testSuite = $configuration->getTestSuiteConfiguration();
     return self::runTest($testSuite, $arguments);
 }
开发者ID:jo-m,项目名称:ecamp3,代码行数:12,代码来源:run.php

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

示例5: load

 /**
  *
  * @param string $suiteClassName        	
  * @param string $suiteClassFile        	
  *
  * @return ReflectionClass
  *
  * @throws PHPUnit_Framework_Exception
  */
 public function load($suiteClassName, $suiteClassFile = '')
 {
     $suiteClassName = str_replace('.php', '', $suiteClassName);
     if (empty($suiteClassFile)) {
         $suiteClassFile = PHPUnit_Util_Filesystem::classNameToFilename($suiteClassName);
     }
     if (!class_exists($suiteClassName, false)) {
         $loadedClasses = get_declared_classes();
         $filename = PHPUnit_Util_Fileloader::checkAndLoad($suiteClassFile);
         $loadedClasses = array_values(array_diff(get_declared_classes(), $loadedClasses));
     }
     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);
         if ($class->getFileName() == realpath($suiteClassFile)) {
             return $class;
         }
     }
     throw new PHPUnit_Framework_Exception(sprintf("Class '%s' could not be found in '%s'.", $suiteClassName, $suiteClassFile));
 }
开发者ID:sapwoo,项目名称:portfolio,代码行数:61,代码来源:StandardTestSuiteLoader.php

示例6: collectTests

 /**
  * @return array
  * @access public
  */
 public function collectTests()
 {
     $includePathsIterator = new AppendIterator();
     $result = array();
     $includePaths = PHPUnit_Util_Fileloader::getIncludePaths();
     foreach ($includePaths as $includePath) {
         $includePathsIterator->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($includePath)));
     }
     $filterIterator = new PHPUnit_Util_FilterIterator($includePathsIterator);
     if ($this->filterIterator !== NULL) {
         $class = new ReflectionClass($this->filterIterator);
         $filterIterator = $class->newInstance($filterIterator);
     }
     foreach ($filterIterator as $file) {
         $result[] = $file;
     }
     return $result;
 }
开发者ID:453111208,项目名称:bbc,代码行数:22,代码来源:IncludePathTestCollector.php

示例7: doRun

 /**
  * @param  PHPUnit_Framework_Test $suite
  * @param  array                  $arguments
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     if (isset($arguments['bootstrap'])) {
         PHPUnit_Util_Fileloader::load($arguments['bootstrap']);
     }
     if (is_integer($arguments['repeat'])) {
         $suite = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups']);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(FALSE);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = FALSE;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = FALSE;
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(TRUE);
     }
     if ($this->printer === NULL) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if (isset($arguments['storyHTMLFile'])) {
         require_once 'PHPUnit/Extensions/Story/ResultPrinter/HTML.php';
         $result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_HTML($arguments['storyHTMLFile']));
     }
     if (isset($arguments['storyTextFile'])) {
         require_once 'PHPUnit/Extensions/Story/ResultPrinter/Text.php';
         $result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_Text($arguments['storyTextFile']));
     }
     if (isset($arguments['testdoxHTMLFile'])) {
         require_once 'PHPUnit/Util/TestDox/ResultPrinter/HTML.php';
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     if (isset($arguments['graphvizLogfile'])) {
         if (PHPUnit_Util_Filesystem::fileExistsInIncludePath('Image/GraphViz.php')) {
             require_once 'PHPUnit/Util/Log/GraphViz.php';
             $result->addListener(new PHPUnit_Util_Log_GraphViz($arguments['graphvizLogfile']));
         }
     }
     if ((isset($arguments['coverageClover']) || isset($arguments['coverageSource']) || isset($arguments['metricsXML']) || isset($arguments['pmdXML']) || isset($arguments['reportDirectory'])) && extension_loaded('xdebug')) {
         $result->collectCodeCoverageInformation(TRUE);
     }
     if (isset($arguments['jsonLogfile'])) {
         require_once 'PHPUnit/Util/Log/JSON.php';
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         require_once 'PHPUnit/Util/Log/TAP.php';
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['xmlLogfile'])) {
         require_once 'PHPUnit/Util/Log/XML.php';
         $result->addListener(new PHPUnit_Util_Log_XML($arguments['xmlLogfile'], $arguments['logIncompleteSkipped']));
     }
     if (isset($arguments['testDatabaseDSN']) && isset($arguments['testDatabaseLogRevision']) && extension_loaded('pdo')) {
         $writeToTestDatabase = TRUE;
     } else {
         $writeToTestDatabase = FALSE;
     }
     if ($writeToTestDatabase) {
         $dbh = PHPUnit_Util_PDO::factory($arguments['testDatabaseDSN']);
         require_once 'PHPUnit/Util/Log/Database.php';
         $dbListener = PHPUnit_Util_Log_Database::getInstance($dbh, $arguments['testDatabaseLogRevision'], isset($arguments['testDatabaseLogInfo']) ? $arguments['testDatabaseLogInfo'] : '');
         $result->addListener($dbListener);
         $result->collectCodeCoverageInformation(TRUE);
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups']);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nWriting code coverage data to XML file, this may take a moment.");
             require_once 'PHPUnit/Util/Log/CodeCoverage/XML/Clover.php';
             $writer = new PHPUnit_Util_Log_CodeCoverage_XML_Clover($arguments['coverageClover']);
//.........这里部分代码省略.........
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:101,代码来源:TestRunner.php

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

示例9: handleArguments


//.........这里部分代码省略.........
             default:
                 $optionName = str_replace('--', '', $option[0]);
                 if (isset($this->longOptions[$optionName])) {
                     $handler = $this->longOptions[$optionName];
                 } else {
                     if (isset($this->longOptions[$optionName . '='])) {
                         $handler = $this->longOptions[$optionName . '='];
                     }
                 }
                 if (isset($handler) && is_callable(array($this, $handler))) {
                     $this->{$handler}($option[1]);
                 }
         }
     }
     $this->handleCustomTestSuite();
     if (!isset($this->arguments['test'])) {
         if (isset($this->options[1][0])) {
             $this->arguments['test'] = $this->options[1][0];
         }
         if (isset($this->options[1][1])) {
             $this->arguments['testFile'] = $this->options[1][1];
         } else {
             $this->arguments['testFile'] = '';
         }
         if (isset($this->arguments['test']) && is_file($this->arguments['test'])) {
             $this->arguments['testFile'] = realpath($this->arguments['test']);
             $this->arguments['test'] = substr($this->arguments['test'], 0, strrpos($this->arguments['test'], '.'));
         }
     }
     if (isset($includePath)) {
         ini_set('include_path', $includePath . PATH_SEPARATOR . ini_get('include_path'));
     }
     if (isset($this->arguments['bootstrap'])) {
         PHPUnit_Util_Fileloader::load($this->arguments['bootstrap']);
     }
     if ($this->arguments['loader'] !== NULL) {
         $this->arguments['loader'] = $this->handleLoader($this->arguments['loader']);
     }
     if (isset($this->arguments['configuration']) && is_dir($this->arguments['configuration'])) {
         $configurationFile = $this->arguments['configuration'] . '/phpunit.xml';
         if (file_exists($configurationFile)) {
             $this->arguments['configuration'] = realpath($configurationFile);
         } else {
             if (file_exists($configurationFile . '.dist')) {
                 $this->arguments['configuration'] = realpath($configurationFile . '.dist');
             }
         }
     } else {
         if (!isset($this->arguments['configuration']) && $this->arguments['useDefaultConfiguration']) {
             if (file_exists('phpunit.xml')) {
                 $this->arguments['configuration'] = realpath('phpunit.xml');
             } else {
                 if (file_exists('phpunit.xml.dist')) {
                     $this->arguments['configuration'] = realpath('phpunit.xml.dist');
                 }
             }
         }
     }
     if (isset($this->arguments['configuration'])) {
         $configuration = PHPUnit_Util_Configuration::getInstance($this->arguments['configuration']);
         $phpunit = $configuration->getPHPUnitConfiguration();
         if (isset($phpunit['testSuiteLoaderClass'])) {
             if (isset($phpunit['testSuiteLoaderFile'])) {
                 $file = $phpunit['testSuiteLoaderFile'];
             } else {
                 $file = '';
开发者ID:robo47,项目名称:phpunit,代码行数:67,代码来源:Command.php

示例10: 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
  * @throws PHPUnit_Framework_Exception
  * @since  Method available since Release 2.3.0
  */
 public function addTestFile($filename)
 {
     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));
         return;
     }
     // The given file may contain further stub classes in addition to the
     // test class itself. Figure out the actual test class.
     $classes = get_declared_classes();
     $filename = PHPUnit_Util_Fileloader::checkAndLoad($filename);
     $newClasses = array_diff(get_declared_classes(), $classes);
     // The diff is empty in case a parent class (with test methods) is added
     // AFTER a child class that inherited from it. To account for that case,
     // cumulate all discovered classes, so the parent class may be found in
     // a later invocation.
     if ($newClasses) {
         // On the assumption that test classes are defined first in files,
         // process discovered classes in approximate LIFO order, so as to
         // avoid unnecessary reflection.
         $this->foundClasses = array_merge($newClasses, $this->foundClasses);
     }
     // The test class's name must match the filename, either in full, or as
     // a PEAR/PSR-0 prefixed shortname ('NameSpace_ShortName'), or as a
     // PSR-1 local shortname ('NameSpace\ShortName'). The comparison must be
     // anchored to prevent false-positive matches (e.g., 'OtherShortName').
     $shortname = basename($filename, '.php');
     $shortnameRegEx = '/(?:^|_|\\\\)' . preg_quote($shortname, '/') . '$/';
     foreach ($this->foundClasses as $i => $className) {
         if (preg_match($shortnameRegEx, $className)) {
             $class = new ReflectionClass($className);
             if ($class->getFileName() == $filename) {
                 $newClasses = [$className];
                 unset($this->foundClasses[$i]);
                 break;
             }
         }
     }
     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));
                 }
             } elseif ($class->implementsInterface('PHPUnit_Framework_Test')) {
                 $this->addTestSuite($class);
             }
         }
     }
     $this->numTests = -1;
 }
开发者ID:441420776,项目名称:phpunit,代码行数:67,代码来源:TestSuite.php

示例11: 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
  */
 public function addTestFile($filename, $syntaxCheck = FALSE, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     // Ensure we can read the file
     if (!$filename || !is_readable($filename)) {
         throw new \RuntimeException(sprintf('Cannot open file "%s".' . "\n", $filename));
     }
     // Try to convert it to a relative path
     if (strpos($filename, getcwd()) === 0) {
         $filename = substr($filename, strlen(getcwd()) + 1);
     } else {
         if (strpos($filename, './') === 0) {
             $filename = substr($filename, strlen('./'));
         }
     }
     // Use stream wrapper for spec files
     $furl = Spec::SCHEME . '://' . $filename;
     // Setup the environment to collect tests
     \DrSlump\Spec::reset($this);
     \PHPUnit_Util_Fileloader::load($furl);
     $this->numTests = -1;
 }
开发者ID:rafeca,项目名称:Spec-PHP,代码行数:39,代码来源:TestSuite.php

示例12: doRun

 /**
  * @param  PHPUnit_Framework_Test $suite
  * @param  array                  $arguments
  * @return PHPUnit_Framework_TestResult
  */
 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     if (isset($arguments['bootstrap'])) {
         $bootstrap = PHPUnit_Util_Fileloader::load($arguments['bootstrap']);
         if ($bootstrap) {
             $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $bootstrap;
         }
     }
     if ($arguments['backupGlobals'] === FALSE) {
         $suite->setBackupGlobals(FALSE);
     }
     if ($arguments['backupStaticAttributes'] === FALSE) {
         $suite->setBackupStaticAttributes(FALSE);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(FALSE);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = FALSE;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = FALSE;
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(TRUE);
     }
     if ($this->printer === NULL) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $this->printer = new PHPUnit_TextUI_ResultPrinter(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP && !self::$versionStringPrinted) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n\n");
     }
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $result->addListener($this->printer);
     if (isset($arguments['storyHTMLFile'])) {
         require_once 'PHPUnit/Extensions/Story/ResultPrinter/HTML.php';
         $result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_HTML($arguments['storyHTMLFile']));
     }
     if (isset($arguments['storyTextFile'])) {
         require_once 'PHPUnit/Extensions/Story/ResultPrinter/Text.php';
         $result->addListener(new PHPUnit_Extensions_Story_ResultPrinter_Text($arguments['storyTextFile']));
     }
     if (isset($arguments['testdoxHTMLFile'])) {
         require_once 'PHPUnit/Util/TestDox/ResultPrinter/HTML.php';
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_HTML($arguments['testdoxHTMLFile']));
     }
     if (isset($arguments['testdoxTextFile'])) {
         require_once 'PHPUnit/Util/TestDox/ResultPrinter/Text.php';
         $result->addListener(new PHPUnit_Util_TestDox_ResultPrinter_Text($arguments['testdoxTextFile']));
     }
     if ((isset($arguments['coverageClover']) || isset($arguments['reportDirectory'])) && extension_loaded('xdebug')) {
         $result->collectCodeCoverageInformation(TRUE);
     }
     if (isset($arguments['logDbus'])) {
         require_once 'PHPUnit/Util/Log/DBUS.php';
         $result->addListener(new PHPUnit_Util_Log_DBUS());
     }
     if (isset($arguments['jsonLogfile'])) {
         require_once 'PHPUnit/Util/Log/JSON.php';
         $result->addListener(new PHPUnit_Util_Log_JSON($arguments['jsonLogfile']));
     }
     if (isset($arguments['tapLogfile'])) {
         require_once 'PHPUnit/Util/Log/TAP.php';
         $result->addListener(new PHPUnit_Util_Log_TAP($arguments['tapLogfile']));
     }
     if (isset($arguments['junitLogfile'])) {
         require_once 'PHPUnit/Util/Log/JUnit.php';
         $result->addListener(new PHPUnit_Util_Log_JUnit($arguments['junitLogfile'], $arguments['logIncompleteSkipped']));
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     unset($suite);
     $result->flushListeners();
     if ($this->printer instanceof PHPUnit_TextUI_ResultPrinter) {
         $this->printer->printResult($result);
     }
     if (extension_loaded('tokenizer') && extension_loaded('xdebug')) {
         if (isset($arguments['coverageClover'])) {
             $this->printer->write("\nWriting code coverage data to XML file, this may take " . 'a moment.');
             require_once 'PHP/CodeCoverage/Report/Clover.php';
             $writer = new PHP_CodeCoverage_Report_Clover();
             $writer->process($result->getCodeCoverage(), $arguments['coverageClover']);
             $this->printer->write("\n");
             unset($writer);
         }
         if (isset($arguments['reportDirectory'])) {
             $this->printer->write("\nGenerating code coverage report, this may take a moment.");
             $title = '';
//.........这里部分代码省略.........
开发者ID:sethcasana,项目名称:phpunit,代码行数:101,代码来源:TestRunner.php

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

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

示例15: _suite

 protected static function _suite($alltests_class, $alltests_file, $sub_suite = null)
 {
     $suite_name = basename($alltests_class, "_AllTests");
     $readable_name = str_replace("_", " ", $suite_name);
     $suite = new PHPUnit_Framework_TestSuite($readable_name);
     $tests = self::_getTests(dirname($alltests_file));
     // trickery to get around the statics problem in php
     eval("\$disabled = " . $alltests_class . "::\$disabled;");
     eval("\$requires_config = " . $alltests_class . "::\$requires_config;");
     foreach ($tests as $test => $filename) {
         $test_file_path = dirname($alltests_file) . DIRECTORY_SEPARATOR . $filename;
         $test_class_name = $suite_name . "_" . $test;
         $test_class_config = ZFTestManager::getConfig($test_class_name);
         if (!is_null($sub_suite) && strpos($test, $sub_suite) === false) {
             continue;
         }
         // if test is disabled by default, and not turned on, continue
         if (in_array($test_class_name, $disabled) && $test_class_config['enabled'] != true) {
             continue;
         }
         // if test is not disabled by default, but is disabled in config, continue
         if (!in_array($test_class_name, $disabled) && $test_class_config['disabled'] == true) {
             continue;
         }
         if (in_array($test_class_name, $requires_config) && $test_class_config === null) {
             echo "Class {$test_class_name} is enabled, but requires config options to be set in TestConfiguration.ini.\n";
             echo "See {$test_file_path} for more details.\n";
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         }
         PHPUnit_Util_Fileloader::checkAndLoad($test_file_path);
         try {
             $suite->addTestSuite($test_class_name);
         } catch (InvalidArgumentException $e) {
             echo "File for {$test_class_name} was loaded, but a class named {$test_class_name} was not found.\n";
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         }
         //$suite->addTestFile($test_file_path);
     }
     return $suite;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:40,代码来源:ZFTestManager.php


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