Skip to content

Commit

Permalink
minor #5133 RuleSetTest - Early return for boolean and detect more de…
Browse files Browse the repository at this point in the history
…faults (SpacePossum)

This PR was merged into the 2.15 branch.

Discussion
----------

RuleSetTest - Early return for boolean and detect more defaults

@ see #5070 (review)

Commits
-------

e9ddf4f Early return for boolean configuration, sort for array to detect more defaults.
  • Loading branch information
SpacePossum committed Oct 4, 2020
2 parents 77ac16f + e9ddf4f commit 163710d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/RuleSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,25 @@ public function testThatDefaultConfigIsNotPassed($setName, $ruleName, $ruleConfi

$fixer = current($factory->getFixers());

if (!$fixer instanceof ConfigurationDefinitionFixerInterface) {
if (!$fixer instanceof ConfigurationDefinitionFixerInterface || \is_bool($ruleConfig)) {
$this->addToAssertionCount(1);

return;
}

$defaultConfig = [];

foreach ($fixer->getConfigurationDefinition()->getOptions() as $option) {
if ($option instanceof DeprecatedFixerOptionInterface) {
continue;
}

$defaultConfig[$option->getName()] = $option->getDefault();
}

ksort($defaultConfig);
ksort($ruleConfig);

static::assertNotSame($defaultConfig, $ruleConfig, sprintf('Rule "%s" (in RuleSet "%s") has default config passed.', $ruleName, $setName));
}

Expand Down

0 comments on commit 163710d

Please sign in to comment.