本文整理汇总了PHP中File_Iterator_Facade::getFilesAsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP File_Iterator_Facade::getFilesAsArray方法的具体用法?PHP File_Iterator_Facade::getFilesAsArray怎么用?PHP File_Iterator_Facade::getFilesAsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File_Iterator_Facade
的用法示例。
在下文中一共展示了File_Iterator_Facade::getFilesAsArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTestsFromDirectoryNodes
/**
* @param \DOMNode $testSuiteNode
* @param array $aggregatedFiles
* @param array $excludes
*/
private function addTestsFromDirectoryNodes(\DOMNode $testSuiteNode, array &$aggregatedFiles, array $excludes)
{
foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) {
$directory = (string) $directoryNode->nodeValue;
$files = $this->fileIteratorFacade->getFilesAsArray($this->relativePath . $directory, $this->getDOMNodeAttribute($directoryNode, 'suffix', 'Test.php'), $this->getDOMNodeAttribute($directoryNode, 'prefix', ''), $excludes);
foreach ($files as $fileName) {
$this->addFileToAggregateArray($aggregatedFiles, $fileName);
}
}
}
示例2: __construct
public function __construct()
{
parent::__construct();
$paths = [];
// Autodiscover extension unit tests
$registry = ExtensionRegistry::getInstance();
foreach ($registry->getAllThings() as $info) {
$paths[] = dirname($info['path']) . '/tests/phpunit';
}
// Extensions can return a list of files or directories
Hooks::run('UnitTestsList', [&$paths]);
foreach (array_unique($paths) as $path) {
if (is_dir($path)) {
// If the path is a directory, search for test cases.
// @since 1.24
$suffixes = ['Test.php'];
$fileIterator = new File_Iterator_Facade();
$matchingFiles = $fileIterator->getFilesAsArray($path, $suffixes);
$this->addTestFiles($matchingFiles);
} elseif (file_exists($path)) {
// Add a single test case or suite class
$this->addTestFile($path);
}
}
if (!$paths) {
$this->addTest(new DummyExtensionsTest('testNothing'));
}
}
示例3: removeDirectoryFromWhitelist
/**
* Removes a directory from the whitelist (recursively).
*
* @param string $directory
* @param string $suffix
* @param string $prefix
*/
public function removeDirectoryFromWhitelist($directory, $suffix = '.php', $prefix = '')
{
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray($directory, $suffix, $prefix);
foreach ($files as $file) {
$this->removeFileFromWhitelist($file);
}
}
示例4: array
function __construct()
{
parent::__construct('DonationInterface test suite');
$suffixes = array('Test.php');
$fileIterator = new File_Iterator_Facade();
$files = $fileIterator->getFilesAsArray(__DIR__, $suffixes);
$this->addTestFiles($files);
}
示例5: testAddingFilesToTheWhitelistWorks
/**
* @covers PHP_CodeCoverage_Filter::addFilesToWhitelist
* @covers PHP_CodeCoverage_Filter::getWhitelist
*/
public function testAddingFilesToTheWhitelistWorks()
{
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray(TEST_FILES_PATH, $suffixes = '.php');
$this->filter->addFilesToWhitelist($files);
$whitelist = $this->filter->getWhitelist();
sort($whitelist);
$this->assertEquals($this->files, $whitelist);
}
示例6: getTest
/**
* 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
* @param mixed $suffixes
* @return PHPUnit_Framework_Test
*/
public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '')
{
if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) {
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray($suiteClassName, $suffixes);
$suite = new PHPUnit_Framework_TestSuite($suiteClassName);
$suite->addTestFiles($files);
return $suite;
}
$testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile);
}
示例7: run
/**
* Run the task.
*
* @param array &$options Additional options.
*
* @return integer Number of errors.
*/
public function run(&$options)
{
require 'PHPDCD/Autoload.php';
$facade = new File_Iterator_Facade();
$result = $facade->getFilesAsArray(array(realpath($this->_config->getPath())), array('php'), array(), array(), true);
$files = $result['files'];
$commonPath = $result['commonPath'];
$detector = new PHPDCD_Detector(new \ezcConsoleOutput());
$result = $detector->detectDeadCode($files, true);
$printer = new PHPDCD_TextUI_ResultPrinter();
$printer->printResult($result, $commonPath);
}
示例8: __construct
/**
* Constructs a new TestSuite for .phpt test cases.
*
* @param string $directory
* @throws PHPUnit_Framework_Exception
*/
public function __construct(string $directory)
{
if (!is_dir($directory)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'directory name');
}
$this->setName($directory);
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray($directory, '.phpt');
foreach ($files as $file) {
$this->addTestFile($file);
}
}
示例9: _checkWithPhpCopyPasteDetector
/**
* Checks the extension with php copy and paste detector
*/
protected function _checkWithPhpCopyPasteDetector()
{
$facade = new \File_Iterator_Facade();
$files = $facade->getFilesAsArray($this->_extensionPath);
$strategy = new \PHPCPD_Detector_Strategy_Default();
$detector = new \PHPCPD_Detector($strategy, null);
try {
$clones = $detector->copyPasteDetection($files, self::PHP_CPD_MIN_LINES, self::PHP_CPD_MIN_TOKENS);
} catch (\Exception $e) {
return;
}
$this->_addIssue(array('type' => 'duplicated_code', 'files' => $clones->getFilesWithClones(), 'comment' => round((double) $clones->getPercentage(), 2), 'occurrences' => $clones->count()));
}
示例10: __construct
/**
* Constructs a new TestSuite for .zept test cases.
*
* @param string $directory
* @throws PHPUnit_Framework_Exception
*/
public function __construct($directory, $silent)
{
if (is_string($directory) && is_dir($directory)) {
$this->setName($directory);
$facade = new \File_Iterator_Facade();
$files = $facade->getFilesAsArray($directory, '.zept');
foreach ($files as $file) {
$this->addTest(new \ZephirTestCase\ZeptTestCase($file, $silent));
}
} else {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'directory name');
}
}
示例11: suite
public static function suite()
{
if (empty($_ENV)) {
if (isset($_SERVER['PATH'])) {
$_ENV['PATH'] = $_SERVER['PATH'];
} else {
$_ENV['PATH'] = getenv('PATH');
}
}
$directory = __DIR__ . '/../../ext/tests/';
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray($directory, '.phpt');
$suite = new PHPUnit_Framework_TestSuite();
foreach ($files as $file) {
$c = file_get_contents($file);
if (!preg_match('/^--(?:PUT|(?:GZIP|DEFLATE)_POST|CGI)--$/m', $c)) {
$suite->addTestFile($file);
}
}
return $suite;
}
示例12: getTest
/**
* 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
* @param mixed $suffixes
*
* @return PHPUnit_Framework_Test
*/
public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '')
{
if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) {
$facade = new File_Iterator_Facade();
$files = $facade->getFilesAsArray($suiteClassName, $suffixes);
$suite = new PHPUnit_Framework_TestSuite($suiteClassName);
$suite->addTestFiles($files);
return $suite;
}
try {
$testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile);
} catch (PHPUnit_Framework_Exception $e) {
$this->runFailed($e->getMessage());
return;
}
try {
$suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME);
if (!$suiteMethod->isStatic()) {
$this->runFailed('suite() method must be static.');
return;
}
try {
$test = $suiteMethod->invoke(null, $testClass->getName());
} catch (ReflectionException $e) {
$this->runFailed(sprintf("Failed to invoke suite() method.\n%s", $e->getMessage()));
return;
}
} catch (ReflectionException $e) {
try {
$test = new PHPUnit_Framework_TestSuite($testClass);
} catch (PHPUnit_Framework_Exception $e) {
$test = new PHPUnit_Framework_TestSuite();
$test->setName($suiteClassName);
}
}
$this->clearStatus();
return $test;
}
示例13: __construct
public function __construct()
{
parent::__construct();
$paths = array();
// Extensions can return a list of files or directories
Hooks::run('UnitTestsList', array(&$paths));
foreach ($paths as $path) {
if (is_dir($path)) {
// If the path is a directory, search for test cases.
// @since 1.24
$suffixes = array('Test.php');
$fileIterator = new File_Iterator_Facade();
$matchingFiles = $fileIterator->getFilesAsArray($path, $suffixes);
$this->addTestFiles($matchingFiles);
} else {
// Add a single test case or suite class
$this->addTestFile($path);
}
}
if (!count($paths)) {
$this->addTest(new DummyExtensionsTest('testNothing'));
}
}
示例14: getTestHelperClassNames
/**
* Get all test helper class names
* @return array
*/
public function getTestHelperClassNames()
{
if (!empty($this->_testHelperClassNames)) {
return $this->_testHelperClassNames;
}
//Get initial path to test helpers
$frameworkConfig = $this->_configHelper->getConfigFramework();
$initialPath = SELENIUM_TESTS_BASEDIR . DIRECTORY_SEPARATOR . $frameworkConfig['testsuite_base_path'];
//Get test helpers sequence
$fallbackOrderHelper = $this->_configHelper->getHelpersFallbackOrder();
$facade = new File_Iterator_Facade();
foreach ($fallbackOrderHelper as $codePoolName) {
$projectPath = $initialPath . DIRECTORY_SEPARATOR . $codePoolName;
if (!is_dir($projectPath)) {
continue;
}
$files = $facade->getFilesAsArray($projectPath, 'Helper.php');
foreach ($files as $file) {
$className = str_replace($initialPath . DIRECTORY_SEPARATOR, '', $file);
$className = str_replace(DIRECTORY_SEPARATOR, '_', str_replace('.php', '', $className));
$array = explode('_', str_replace('_Helper', '', $className));
$helperName = end($array);
$this->_testHelperClassNames[$helperName] = $className;
}
}
return $this->_testHelperClassNames;
}
示例15: run
/**
* Runs a suite of unit tests
*
* @param string $directory Directory with tests.
* @param string $suffix Test file suffix.
* @throws \Exception When invalid test found.
* @return boolean
*/
public function run($directory, $suffix)
{
$this->resultPrinter->suiteHeader($this, $directory . '/*' . $suffix);
$passed = true;
$facade = new \File_Iterator_Facade();
$old_handler = set_error_handler(array($this, 'handlePHPErrors'));
foreach ($facade->getFilesAsArray($directory, $suffix) as $path) {
$test = (require $path);
if (!$test instanceof xTest) {
throw new \Exception("'{$path}' is not a valid unit test");
}
$test->setResultPrinter($this->resultPrinter);
$passed = $passed && $test->run($this);
}
if ($old_handler) {
set_error_handler($old_handler);
} else {
restore_error_handler();
}
$this->resultPrinter->createCodeCoverageReport($this->coverage);
$this->resultPrinter->suiteFooter($this);
return $passed;
}