Skip to content

Commit b987cad

Browse files
Add contains string to FlipAssertRector (#444)
* add failing fixture * add contains string to flip assert * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
1 parent a711439 commit b987cad

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;
4+
5+
use PHPUnit\Framework\Assert;
6+
7+
final class CoverStaticCall extends \PHPUnit\Framework\TestCase
8+
{
9+
public function test()
10+
{
11+
$result = '...';
12+
Assert::assertStringContainsString($result, 'expected');
13+
}
14+
}
15+
16+
?>
17+
-----
18+
<?php
19+
20+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\FlipAssertRector\Fixture;
21+
22+
use PHPUnit\Framework\Assert;
23+
24+
final class CoverStaticCall extends \PHPUnit\Framework\TestCase
25+
{
26+
public function test()
27+
{
28+
$result = '...';
29+
Assert::assertStringContainsString('expected', $result);
30+
}
31+
}
32+
33+
?>

rules/CodeQuality/Rector/MethodCall/FlipAssertRector.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ public function getNodeTypes(): array
7878
*/
7979
public function refactor(Node $node): ?Node
8080
{
81-
if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertSame', 'assertEquals'])) {
81+
if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames(
82+
$node,
83+
['assertSame', 'assertEquals', 'assertStringContainsString']
84+
)) {
8285
return null;
8386
}
8487

0 commit comments

Comments
 (0)