/** * @covers PHP_CodeCoverage_Filter::addFilesToWhitelist * @covers PHP_CodeCoverage_Filter::getBlacklist */ public function testAddingFilesToTheWhitelistWorks() { $this->filter->addFilesToWhitelist(File_Iterator_Factory::getFilesAsArray(TEST_FILES_PATH, $suffixes = '.php')); $whitelist = $this->filter->getWhitelist(); sort($whitelist); $this->assertEquals($this->files, $whitelist); }
/** * Iterates over the project files * and calls replace token on each * * @uses pear.phpunit.de/File_Iterator */ private function _iterate() { require_once 'File/Iterator/Factory.php'; $files = File_Iterator_Factory::getFilesAsArray($this->_applicationRoot, $this->_allowedExtensions); foreach ($files as $file) { $this->_replaceToken($file); } }
/** * Returns the Test corresponding to the given suite. * This is a template method, subclasses override * the runFailed() and clearStatus() methods. * * @param string $suiteClassName * @param string $suiteClassFile * @return PHPUnit_Framework_Test */ public function getTest($suiteClassName, $suiteClassFile = '') { if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { $suite = new PHPUnit_Framework_TestSuite($suiteClassName); $suite->addTestFiles( File_Iterator_Factory::getFilesAsArray( $suiteClassName, array('Test.php', '.phpt') ) ); return $suite; } try { $testClass = $this->loadSuiteClass( $suiteClassName, $suiteClassFile ); } catch (Exception $e) { $this->runFailed($e->getMessage()); return NULL; } try { $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); if (!$suiteMethod->isStatic()) { $this->runFailed( 'suite() method must be static.' ); return NULL; } try { $test = $suiteMethod->invoke(NULL, $testClass->getName()); } catch (ReflectionException $e) { $this->runFailed( sprintf( "Failed to invoke suite() method.\n%s", $e->getMessage() ) ); return NULL; } } catch (ReflectionException $e) { try { $test = new PHPUnit_Framework_TestSuite($testClass); } catch (InvalidArgumentException $e) { $test = new PHPUnit_Framework_TestSuite; $test->setName($suiteClassName); } } $this->clearStatus(); return $test; }
/** * @param DOMElement $testSuiteNode * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode) { if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite((string) $testSuiteNode->getAttribute('name')); } else { $suite = new PHPUnit_Framework_TestSuite(); } foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { $directory = (string) $directoryNode->nodeValue; if (empty($directory)) { continue; } if ($directoryNode->hasAttribute('prefix')) { $prefix = (string) $directoryNode->getAttribute('prefix'); } else { $prefix = ''; } if ($directoryNode->hasAttribute('suffix')) { $suffix = (string) $directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $suite->addTestFiles(File_Iterator_Factory::getFilesAsArray($this->toAbsolutePath($directory), $suffix, $prefix, array())); } foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { $file = (string) $fileNode->nodeValue; if (empty($file)) { continue; } $suite->addTestFile($file); } return $suite; }