Skip to content

Commit

Permalink
Let unit tests run multiple sniffs if they want to
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Oct 30, 2017
1 parent 429e031 commit ac151a8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ public function __construct(Config $config)
}

if (defined('PHP_CODESNIFFER_IN_TESTS') === true && empty($restrictions) === false) {
// Unit tests use one standard and one sniff at a time.
// In unit tests, only register the sniffs that the test wants and not the entire standard.
try {
$sniffs = $this->expandRulesetReference($restrictions[0], dirname($standard));
foreach ($restrictions as $restriction) {
$sniffs = array_merge($sniffs, $this->expandRulesetReference($restriction, dirname($standard)));
}
} catch (RuntimeException $e) {
// Sniff reference could not be expanded, which probably means this
// is an installed standard. Let the unit test system take care of
Expand Down

0 comments on commit ac151a8

Please sign in to comment.