File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed
rules-tests/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector/Fixture
rules/PHPUnit120/Rector/MethodCall Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \PHPUnit120 \Rector \MethodCall \ExplicitMockExpectsCallRector \Fixture ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+
7+ final class SkipAlreadyFilled extends TestCase
8+ {
9+ public function testMethod (): void
10+ {
11+ $ someClass = $ this ->createMock (\stdClass::class);
12+
13+ $ someClass ->expects ($ this ->once ())->method ('some ' );
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Rector \PHPUnit \Tests \PHPUnit120 \Rector \MethodCall \ExplicitMockExpectsCallRector \Fixture ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+
7+ final class SkipSetupAsCanBeAny extends TestCase
8+ {
9+ protected function setUp (): void
10+ {
11+ $ someClass = $ this ->createMock (\stdClass::class);
12+
13+ $ someClass ->method ('some ' );
14+ }
15+ }
Original file line number Diff line number Diff line change 1010use PhpParser \Node \Expr \PropertyFetch ;
1111use PhpParser \Node \Expr \Variable ;
1212use PHPStan \Type \ObjectType ;
13+ use Rector \PHPStan \ScopeFetcher ;
1314use Rector \PHPUnit \Enum \PHPUnitClassName ;
1415use Rector \PHPUnit \NodeAnalyzer \TestsNodeAnalyzer ;
1516use Rector \Rector \AbstractRector ;
17+ use Rector \ValueObject \MethodName ;
1618use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1719use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
1820
@@ -80,6 +82,11 @@ public function refactor(Node $node): Node|null
8082 return null ;
8183 }
8284
85+ $ scope = ScopeFetcher::fetch ($ node );
86+ if ($ scope ->getFunctionName () === MethodName::SET_UP ) {
87+ return null ;
88+ }
89+
8390 if (! $ node ->var instanceof Variable && ! $ node ->var instanceof PropertyFetch) {
8491 return null ;
8592 }
You can’t perform that action at this time.
0 commit comments