-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check paths are accepted if no exclude-pattern matches.
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd"> | ||
<description>The coding standard for PHP_CodeSniffer itself.</description> | ||
|
||
<rule ref="Generic"> | ||
<exclude-pattern>/anything/</exclude-pattern> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* Tests for the \PHP_CodeSniffer\Filters\Filter::accept method. | ||
* | ||
* @author Willington Vega <wvega@wvega.com> | ||
* @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 |