Browse Source

Use expectNotToPerformAssertions where applicable

SpacePossum 3 years ago
parent
commit
2b03444c6a

+ 12 - 15
tests/AutoReview/ProjectCodeTest.php

@@ -229,7 +229,7 @@ final class ProjectCodeTest extends TestCase
         );
 
         if ([] === $publicMethods) {
-            $this->addToAssertionCount(1); // no methods to test, all good!
+            $this->expectNotToPerformAssertions(); // no methods to test, all good!
 
             return;
         }
@@ -261,7 +261,7 @@ final class ProjectCodeTest extends TestCase
         }
 
         if (0 === $asserts) {
-            $this->addToAssertionCount(1); // no data providers to test, all good!
+            $this->expectNotToPerformAssertions(); // no data providers to test, all good!
         }
     }
 
@@ -281,7 +281,7 @@ final class ProjectCodeTest extends TestCase
         );
 
         if ([] === $definedDataProviders) {
-            $this->addToAssertionCount(1); // no methods to test, all good!
+            $this->expectNotToPerformAssertions(); // no methods to test, all good!
 
             return;
         }
@@ -309,7 +309,7 @@ final class ProjectCodeTest extends TestCase
         $reflectionClass = new \ReflectionClass($testClassName);
 
         if ($reflectionClass->isAbstract() || $reflectionClass->isInterface()) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }
@@ -318,7 +318,7 @@ final class ProjectCodeTest extends TestCase
         static::assertNotFalse($doc);
 
         if (1 === Preg::match('/@coversNothing/', $doc, $matches)) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }
@@ -332,13 +332,10 @@ final class ProjectCodeTest extends TestCase
         $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)
+            );
         }
     }
 
@@ -389,7 +386,7 @@ final class ProjectCodeTest extends TestCase
         );
 
         if ([] === $publicMethods) {
-            $this->addToAssertionCount(1); // no methods to test, all good!
+            $this->expectNotToPerformAssertions(); // no methods to test, all good!
 
             return;
         }
@@ -493,7 +490,7 @@ final class ProjectCodeTest extends TestCase
     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;
         }
@@ -710,7 +707,7 @@ final class ProjectCodeTest extends TestCase
         $reflectionClassConstants = $rc->getReflectionConstants();
 
         if (\count($reflectionClassConstants) < 1) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }

+ 1 - 1
tests/AutoReview/TransformerTest.php

@@ -49,7 +49,7 @@ final class TransformerTest extends TestCase
         $priority = $transformer->getPriority();
 
         if (0 === $priority) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }

+ 1 - 1
tests/RuleSet/RuleSetTest.php

@@ -79,7 +79,7 @@ final class RuleSetTest extends TestCase
         $fixer = current($factory->getFixers());
 
         if (!$fixer instanceof ConfigurableFixerInterface || \is_bool($ruleConfig)) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }

+ 2 - 2
tests/Test/AbstractFixerTestCase.php

@@ -248,7 +248,7 @@ abstract class AbstractFixerTestCase extends TestCase
 
         // if there is no `insertAt`, it's not a candidate
         if (!\in_array('insertAt', $usedMethods, true)) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }
@@ -310,7 +310,7 @@ abstract class AbstractFixerTestCase extends TestCase
     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;
         }

+ 1 - 1
tests/Test/AbstractTransformerTestCase.php

@@ -92,7 +92,7 @@ abstract class AbstractTransformerTestCase extends TestCase
     public function testTransformDoesNotChangeSimpleCode(): void
     {
         if (\PHP_VERSION_ID < $this->transformer->getRequiredPhpVersionId()) {
-            $this->addToAssertionCount(1);
+            $this->expectNotToPerformAssertions();
 
             return;
         }