Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Rename methods and variables #268

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions test/Unit/RuleSet/AbstractRuleSetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,56 +48,56 @@ final public function testDefaults(): void
self::assertEquals($this->targetPhpVersion, $ruleSet->targetPhpVersion());
}

final public function testRulesDoNotConfigureRuleSets(): void
final public function testRuleSetDoesNotConfigureRuleSets(): void
{
$ruleNames = \array_keys(self::createRuleSet()->rules());
$namesOfRulesThatAreConfigured = \array_keys(self::createRuleSet()->rules());

$namesOfConfiguredRuleSets = \array_filter($ruleNames, static function (string $ruleName): bool {
$namesOfRulesThatAreConfiguredAndReferenceRuleSets = \array_filter($namesOfRulesThatAreConfigured, static function (string $ruleName): bool {
return '@' === \mb_substr($ruleName, 0, 1);
});

self::assertEmpty($namesOfConfiguredRuleSets, \sprintf(
self::assertEmpty($namesOfRulesThatAreConfiguredAndReferenceRuleSets, \sprintf(
"Failed asserting that rule set \"%s\" does not configure rule sets. Rule sets with names\n\n%s\n\nshould not be used.",
static::className(),
' - ' . \implode("\n - ", $namesOfConfiguredRuleSets)
' - ' . \implode("\n - ", $namesOfRulesThatAreConfiguredAndReferenceRuleSets)
));
}

final public function testRulesDoNotConfigureUnknownFixers(): void
final public function testRuleSetDoesDoNotConfigureRulesThatAreNotBuiltIn(): void
{
$namesOfUnknownFixers = \array_diff(
self::namesOfConfiguredFixers(),
self::namesOfKnownFixers()
$namesOfRulesThatAreConfiguredAndNotBuiltIn = \array_diff(
self::namesOfRulesThatAreConfigured(),
self::namesOfRulesThatAreBuiltIn()
);

\sort($namesOfUnknownFixers);
\sort($namesOfRulesThatAreConfiguredAndNotBuiltIn);

self::assertEmpty($namesOfUnknownFixers, \sprintf(
"Failed asserting that rule set \"%s\" configures only known fixers. Fixers with names\n\n%s\n\nare unknown.",
self::assertEmpty($namesOfRulesThatAreConfiguredAndNotBuiltIn, \sprintf(
"Failed asserting that rule set \"%s\" configures only built-in rules. Rules with names\n\n%s\n\nare unknown.",
static::className(),
' - ' . \implode("\n - ", $namesOfUnknownFixers)
' - ' . \implode("\n - ", $namesOfRulesThatAreConfiguredAndNotBuiltIn)
));
}

final public function testRulesDoNotConfigureDeprecatedFixers(): void
final public function testRuleSetDoesNotConfigureRulesThatAreDeprecated(): void
{
$namesOfConfiguredDeprecatedFixers = \array_diff(
self::namesOfConfiguredFixers(),
self::namesOfNonDeprecatedFixers()
$namesOfRulesThatAreConfiguredAndDeprecated = \array_diff(
self::namesOfRulesThatAreConfigured(),
self::namesOfRulesThatAreNotDeprecated()
);

self::assertEmpty($namesOfConfiguredDeprecatedFixers, \sprintf(
"Failed asserting that rule set \"%s\" does not configure deprecated fixers. Fixers with names\n\n%s\n\nare deprecated.",
self::assertEmpty($namesOfRulesThatAreConfiguredAndDeprecated, \sprintf(
"Failed asserting that rule set \"%s\" does not configure deprecated rules. Rules with names\n\n%s\n\nare deprecated.",
static::className(),
' - ' . \implode("\n - ", $namesOfConfiguredDeprecatedFixers)
' - ' . \implode("\n - ", $namesOfRulesThatAreConfiguredAndDeprecated)
));
}

final public function testRulesConfigureAllNonDeprecatedFixers(): void
final public function testRuleSetConfiguresAllFixersThatAreNotDeprecated(): void
{
$namesOfNonDeprecatedFixersWithoutConfiguration = \array_diff(
self::namesOfNonDeprecatedFixers(),
self::namesOfKnownFixers()
self::namesOfRulesThatAreNotDeprecated(),
self::namesOfRulesThatAreBuiltIn()
);

\sort($namesOfNonDeprecatedFixersWithoutConfiguration);
Expand All @@ -109,7 +109,7 @@ final public function testRulesConfigureAllNonDeprecatedFixers(): void
));
}

final public function testRulesAreSortedByName(): void
final public function testRulesAreSortedByNameInRuleSet(): void
{
$ruleNames = \array_keys(self::createRuleSet()->rules());

Expand Down Expand Up @@ -246,7 +246,7 @@ final protected static function createRuleSet(?string $header = null): Config\Ru
/**
* @return array<string, Fixer\FixerInterface>
*/
private static function builtInFixers(): array
private static function fixersThatAreBuiltIn(): array
{
$fixerFactory = FixerFactory::create();

Expand All @@ -270,7 +270,7 @@ private static function builtInFixers(): array
/**
* @return array<int, string>
*/
private static function namesOfConfiguredFixers(): array
private static function namesOfRulesThatAreConfigured(): array
{
/**
* RuleSet::create() removes disabled fixers, to let's just enable them to make sure they are not removed.
Expand All @@ -294,17 +294,17 @@ private static function namesOfConfiguredFixers(): array
/**
* @return array<int, string>
*/
private static function namesOfKnownFixers(): array
private static function namesOfRulesThatAreBuiltIn(): array
{
return \array_keys(self::builtInFixers());
return \array_keys(self::fixersThatAreBuiltIn());
}

/**
* @return array<int, string>
*/
private static function namesOfNonDeprecatedFixers(): array
private static function namesOfRulesThatAreNotDeprecated(): array
{
return \array_keys(\array_filter(self::builtInFixers(), static function (Fixer\FixerInterface $fixer): bool {
return \array_keys(\array_filter(self::fixersThatAreBuiltIn(), static function (Fixer\FixerInterface $fixer): bool {
return !$fixer instanceof Fixer\DeprecatedFixerInterface;
}));
}
Expand Down