diff --git a/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/nested_callback.php.inc b/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/nested_callback.php.inc index 1e1bb134..a38f250a 100644 --- a/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/nested_callback.php.inc +++ b/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/nested_callback.php.inc @@ -38,7 +38,7 @@ final class NestedCallback extends TestCase $this->someMock->expects($matcher) ->method('prepare') ->willReturnCallback( - function (...$parameters) use ($matcher) { + function (...$parameters) use ($matcher, $item) { if ($matcher->numberOfInvocations() === 1) { $this->assertEquals(50, $parameters[0]); $this->assertSame(5, $parameters[1]); diff --git a/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/skip_nested_variable_from_uses.php.inc b/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/skip_nested_variable_from_uses.php.inc index 18426458..61f22c3d 100644 --- a/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/skip_nested_variable_from_uses.php.inc +++ b/rules-tests/PHPUnit100/Rector/StmtsAwareInterface/WithConsecutiveRector/Fixture/skip_nested_variable_from_uses.php.inc @@ -32,7 +32,7 @@ final class SkipNestedVariableFromUses extends TestCase $this->someMock->expects($matcher) ->method('prepare') ->willReturnCallback( - function (...$parameters) use ($matcher) { + function (...$parameters) use ($matcher, $item) { $this->assertSame(5, $parameters[0]); }, ); diff --git a/tests/Issues/MockToStubSetupCombined/Fixture/some_test.php.inc b/tests/Issues/MockToStubSetupCombined/Fixture/some_test.php.inc new file mode 100644 index 00000000..0e5a7fd3 --- /dev/null +++ b/tests/Issues/MockToStubSetupCombined/Fixture/some_test.php.inc @@ -0,0 +1,63 @@ +someMock = $this->createMock(MockedClass::class); + + $generator = new RewindableGenerator(fn () => yield from [ + $this->someMock, + ], 2); + } + + public function testSomething(): void + { + } + + public function testAnother(): void + { + } +} + +?> +----- +createMock(MockedClass::class); + + $generator = new RewindableGenerator(fn () => yield from [ + $someMock, + ], 2); + } + + public function testSomething(): void + { + } + + public function testAnother(): void + { + } +} + +?> diff --git a/tests/Issues/MockToStubSetupCombined/MockToStubSetupCombinedTest.php b/tests/Issues/MockToStubSetupCombined/MockToStubSetupCombinedTest.php new file mode 100644 index 00000000..ea599222 --- /dev/null +++ b/tests/Issues/MockToStubSetupCombined/MockToStubSetupCombinedTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/tests/Issues/MockToStubSetupCombined/Source/MockedClass.php b/tests/Issues/MockToStubSetupCombined/Source/MockedClass.php new file mode 100644 index 00000000..efdc9199 --- /dev/null +++ b/tests/Issues/MockToStubSetupCombined/Source/MockedClass.php @@ -0,0 +1,7 @@ +withRules(rules: [ + NarrowUnusedSetUpDefinedPropertyRector::class, + BareCreateMockAssignToDirectUseRector::class, + ]);