diff --git a/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Fixture/final_property_as_well.php.inc b/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Fixture/final_property_as_well.php.inc new file mode 100644 index 00000000..82c573a3 --- /dev/null +++ b/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Fixture/final_property_as_well.php.inc @@ -0,0 +1,56 @@ +someMock = $this->createMock(SomeFinalClass::class); + $this->someMock->method('some')->willReturn(true); + } + + public function testOne() + { + } + + public function testTwo() + { + } +} + +?> +----- +someMock = $this->createMock(SomeFinalClass::class); + $this->someMock->method('some')->willReturn(true); + } + + public function testOne() + { + } + + public function testTwo() + { + } +} + +?> diff --git a/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Source/SomeFinalClass.php b/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Source/SomeFinalClass.php new file mode 100644 index 00000000..f3419b06 --- /dev/null +++ b/rules-tests/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector/Source/SomeFinalClass.php @@ -0,0 +1,8 @@ +isObjectType($methodCall->var, new ObjectType(PHPUnitClassName::MOCK_OBJECT))) { - continue; + if ($methodCall->var instanceof Variable || $methodCall->var instanceof PropertyFetch) { + return true; } - - return true; } return false;