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

Use expectNotToPerformAssertions where applicable #6232

Merged
merged 1 commit into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 12 additions & 15 deletions tests/AutoReview/ProjectCodeTest.php
Expand Up @@ -229,7 +229,7 @@ static function (\ReflectionMethod $reflectionMethod) use ($reflectionClass): bo
);

if ([] === $publicMethods) {
$this->addToAssertionCount(1); // no methods to test, all good!
$this->expectNotToPerformAssertions(); // no methods to test, all good!

return;
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public function testThatTestDataProvidersAreCorrectlyNamed(string $testClassName
}

if (0 === $asserts) {
$this->addToAssertionCount(1); // no data providers to test, all good!
$this->expectNotToPerformAssertions(); // no data providers to test, all good!
}
}

Expand All @@ -281,7 +281,7 @@ static function (\ReflectionMethod $reflectionMethod) use ($reflectionClass): bo
);

if ([] === $definedDataProviders) {
$this->addToAssertionCount(1); // no methods to test, all good!
$this->expectNotToPerformAssertions(); // no methods to test, all good!

return;
}
Expand Down Expand Up @@ -309,7 +309,7 @@ public function testThatTestClassCoversAreCorrect(string $testClassName): void
$reflectionClass = new \ReflectionClass($testClassName);

if ($reflectionClass->isAbstract() || $reflectionClass->isInterface()) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand All @@ -318,7 +318,7 @@ public function testThatTestClassCoversAreCorrect(string $testClassName): void
static::assertNotFalse($doc);

if (1 === Preg::match('/@coversNothing/', $doc, $matches)) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand All @@ -332,13 +332,10 @@ public function testThatTestClassCoversAreCorrect(string $testClassName): void
$parentClassName = false === $parentClass ? null : '\\'.$parentClass->getName();

foreach ($matches as $match) {
if ($match === $class || $parentClassName === $match) {
$this->addToAssertionCount(1);

continue;
}

static::fail(sprintf('Unexpected @covers "%s" for "%s".', $match, $testClassName));
static::assertTrue(
$match === $class || $parentClassName === $match,
sprintf('Unexpected @covers "%s" for "%s".', $match, $testClassName)
);
}
}

Expand Down Expand Up @@ -389,7 +386,7 @@ static function (\ReflectionMethod $reflectionMethod) use ($reflectionClass): bo
);

if ([] === $publicMethods) {
$this->addToAssertionCount(1); // no methods to test, all good!
$this->expectNotToPerformAssertions(); // no methods to test, all good!

return;
}
Expand Down Expand Up @@ -493,7 +490,7 @@ public function testAllCodeContainSingleClassy(string $className): void
public function testThereIsNoTriggerErrorUsedDirectly(string $className): void
{
if (Utils::class === $className) {
$this->addToAssertionCount(1); // This is where "trigger_error" should be
$this->expectNotToPerformAssertions(); // This is where "trigger_error" should be

return;
}
Expand Down Expand Up @@ -710,7 +707,7 @@ public function testConstantsAreInUpperCase(string $className): void
$reflectionClassConstants = $rc->getReflectionConstants();

if (\count($reflectionClassConstants) < 1) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/AutoReview/TransformerTest.php
Expand Up @@ -49,7 +49,7 @@ public function testTransformerPriorityIsListed(TransformerInterface $transforme
$priority = $transformer->getPriority();

if (0 === $priority) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/RuleSet/RuleSetTest.php
Expand Up @@ -79,7 +79,7 @@ public function testThatDefaultConfigIsNotPassed(string $setName, string $ruleNa
$fixer = current($factory->getFixers());

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

return;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Test/AbstractFixerTestCase.php
Expand Up @@ -248,7 +248,7 @@ public function testFixerUseInsertSlicesWhenOnlyInsertionsArePerformed(): void

// if there is no `insertAt`, it's not a candidate
if (!\in_array('insertAt', $usedMethods, true)) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ public function testFixerUseInsertSlicesWhenOnlyInsertionsArePerformed(): void
final public function testFixerConfigurationDefinitions(): void
{
if (!$this->fixer instanceof ConfigurableFixerInterface) {
$this->addToAssertionCount(1); // not applied to the fixer without configuration
$this->expectNotToPerformAssertions(); // not applied to the fixer without configuration

return;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/AbstractTransformerTestCase.php
Expand Up @@ -92,7 +92,7 @@ public function testTransformersIsFinal(): void
public function testTransformDoesNotChangeSimpleCode(): void
{
if (\PHP_VERSION_ID < $this->transformer->getRequiredPhpVersionId()) {
$this->addToAssertionCount(1);
$this->expectNotToPerformAssertions();

return;
}
Expand Down