Rector: @doesNotPerformAssertions added when expectException is used

Created on 28 Oct 2019  路  5Comments  路  Source: rectorphp/rector

| Subject | Details |
| :------------- | :----------------------------------------------------------- |
| Rector version | Rector v0.5.19 |
| PHP version | PHP 7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b (cli) (built: May 3 2019 09:38:28) |
| Full Command | vendor/bin/rector process -s=phpunit60 -c rector.yaml |

Current Behaviour

Output after running rector:


+    /**
+     * @doesNotPerformAssertions
+     */
     public function testInvalidType(): void
     {
-        $this->setExpectedException(InvalidArgumentException::class);
+        $this->expectException(InvalidArgumentException::class);
         new CustomerType("foo");
     }
 }

Minimal PHP Code Causing Issue

<?php 
class FooTest extends \PHPUnit\Framework\TestCase
 {
     public function testInvalidType(): void
     {
        $this->expectException(InvalidArgumentException::class);
         new CustomerType("foo");
     }
 }

Expected Behaviour

Code should NOT have the @doesNotPerformAssertions added because $this->expectException(InvalidArgumentException::class); is an assertion.

bug

All 5 comments

This fix is easy, as it already checks for expectException.
Would you like to try to tfix that or shall I?

I'll take a look

Proposed fix in PR #2217

Closed by #2217

Was this page helpful?
0 / 5 - 0 ratings