[AddDoesNotPerformAssertionToNonAssertingTestRector] fix skippi… (#2636)

[AddDoesNotPerformAssertionToNonAssertingTestRector] fix skipping if annotation already exists (fixes infinite loop too)
This commit is contained in:
Tomas Votruba 2020-01-11 10:32:28 +01:00 committed by GitHub
commit 9cac83e364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -131,7 +131,7 @@ PHP
if ($classMethod->getDocComment() !== null) {
$text = $classMethod->getDocComment();
if (Strings::match($text->getText(), '#@expectedException\b#')) {
if (Strings::match($text->getText(), '#@(doesNotPerformAssertion|expectedException\b)#')) {
return true;
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Rector\PHPUnit\Tests\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector\Fixture;
class SkipExistingAnnotation extends \PHPUnit\Framework\TestCase
{
/**
* @doesNotPerformAssertion
*/
public function testSomething(): void
{
}
}