diff --git a/tests/Core/AllTests.php b/tests/Core/AllTests.php index 36a98a9ba7..a9320e36aa 100644 --- a/tests/Core/AllTests.php +++ b/tests/Core/AllTests.php @@ -21,6 +21,7 @@ require_once 'File/GetMethodParametersTest.php'; require_once 'File/GetMethodPropertiesTest.php'; require_once 'File/IsReferenceTest.php'; +require_once 'Filters/Filter/AcceptTest.php'; class AllTests { @@ -55,6 +56,7 @@ public static function suite() $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest'); $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodPropertiesTest'); $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\IsReferenceTest'); + $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\Filters\Filter\AcceptTest'); return $suite; }//end suite() diff --git a/tests/Core/Filters/Filter/AcceptTest.inc b/tests/Core/Filters/Filter/AcceptTest.inc new file mode 100644 index 0000000000..c5aea6d9c1 --- /dev/null +++ b/tests/Core/Filters/Filter/AcceptTest.inc @@ -0,0 +1,8 @@ + + + The coding standard for PHP_CodeSniffer itself. + + + /anything/ + + diff --git a/tests/Core/Filters/Filter/AcceptTest.php b/tests/Core/Filters/Filter/AcceptTest.php new file mode 100644 index 0000000000..4836afa1c7 --- /dev/null +++ b/tests/Core/Filters/Filter/AcceptTest.php @@ -0,0 +1,49 @@ + + * @copyright 2006-2018 Squiz Pty Ltd (ABN 77 084 670 600) + * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence + */ + +namespace PHP_CodeSniffer\Tests\Core\Filters\Filter; + +use PHP_CodeSniffer\Config; +use PHP_CodeSniffer\Filters\Filter; +use PHP_CodeSniffer\Ruleset; +use PHPUnit\Framework\TestCase; + +class AcceptTest extends TestCase +{ + + + /** + * Test paths that include the name of a standard with associated + * exclude-patterns are still accepted. + * + * @return void + */ + public function testExcludePatternsForStandards() + { + $standard = __DIR__.'/'.basename(__FILE__, '.php').'.inc'; + $config = new Config(["--standard=$standard"]); + $ruleset = new Ruleset($config); + + $paths = ['/path/to/generic-project/src/Main.php']; + + $fakeDI = new \RecursiveArrayIterator($paths); + $filter = new Filter($fakeDI, '/path/to/generic-project/src', $config, $ruleset); + $iterator = new \RecursiveIteratorIterator($filter); + $files = []; + + foreach ($iterator as $file) { + $files[] = $file; + } + + $this->assertEquals($paths, $files); + + }//end testExcludePatternsForStandards() + + +}//end class