/** * Creates an array with those files that were acceptable for the exclude * path filter. * * @param array(string) $excludes The filtered patterns * * @return array(string) */ protected function createFilteredFileList(array $excludes) { $filter = new PHP_Depend_Input_ExcludePathFilter($excludes); $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(self::createCodeResourceUriForTest())); $actual = array(); foreach ($files as $file) { if ($filter->accept($file, $file) && $file->isFile() && false === stripos($file->getPathname(), '.svn')) { $actual[] = $file->getFilename(); } } sort($actual); return $actual; }
/** * Tests the path exclude filter with a mix of files and directories. * * @return void */ public function testExcludePathFilterWithFileAndDirectory() { $filter = new PHP_Depend_Input_ExcludePathFilter(array('/code-5.3.x/', '/code-5.2.x/package1.php', '/code-without-comments/', '/function.inc')); $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/../_code')); $result = array(); foreach ($it as $file) { if ($filter->accept($file)) { $result[$file->getFilename()] = true; } } $this->assertArrayHasKey('package2.php', $result); $this->assertArrayHasKey('invalid_class_with_code.txt', $result); $this->assertArrayNotHasKey('pkg3FooI.txt', $result); $this->assertArrayNotHasKey('package1.php', $result); $this->assertArrayNotHasKey('function.inc', $result); }
/** * testAbsoluteWindowsPathAsFilterPattern * * @return void * @group pdepend * @group pdepend::bugs * @group regressiontest */ public function testAbsoluteWindowsPathAsFilterPattern() { $filter = new PHP_Depend_Input_ExcludePathFilter(array('c:\\workspace\\bar')); self::assertFalse($filter->accept('\\baz', 'c:\\workspace\\bar\\baz')); }