Skip to content

[PHPUnit60] Remove addToAssertionCount() calls in AddDoesNotPerformAssertionToNonAssertingTestRector - #763

Merged
TomasVotruba merged 1 commit into
mainfrom
remove-add-to-assertion-count
Aug 8, 2026
Merged

[PHPUnit60] Remove addToAssertionCount() calls in AddDoesNotPerformAssertionToNonAssertingTestRector#763
TomasVotruba merged 1 commit into
mainfrom
remove-add-to-assertion-count

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Once the @doesNotPerformAssertions annotation is added, any $this->addToAssertionCount(1); call in that method is dead weight - it only existed to fake an assertion so the test would not be reported as risky. The rule now removes those calls, including a trailing same-line comment.

 class SomeTest extends TestCase
 {
+    /**
+     * @doesNotPerformAssertions
+     */
     public function test()
     {
         $this->someMethodCall();
-
-        $this->addToAssertionCount(1); // Verify that no exception is thrown
     }
 }

Nested calls are handled too, e.g. inside try/catch blocks. Methods that do contain a real assertion are skipped as before, so their addToAssertionCount() calls stay untouched.

@TomasVotruba
TomasVotruba merged commit 2db2e4c into main Aug 8, 2026
7 checks passed
@TomasVotruba
TomasVotruba deleted the remove-add-to-assertion-count branch August 8, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant