From 9537c65d1a1c3c010569e07adb6b7f99fd575dda Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Tue, 17 Nov 2026 16:03:31 +0100 Subject: [PATCH] [PHPUnit120] Remove deprecated AllowMockObjectsWithoutExpectationsAttributeRector --- ...ectsWithoutExpectationsAttributeRector.php | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 rules/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector.php diff --git a/rules/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector.php b/rules/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector.php deleted file mode 100644 index ec8559ed..00000000 --- a/rules/PHPUnit120/Rector/Class_/AllowMockObjectsWithoutExpectationsAttributeRector.php +++ /dev/null @@ -1,102 +0,0 @@ -someServiceMock = $this->createMock(SomeService::class); - } - - public function testOne(): void - { - // use $this->someServiceMock - } - - public function testTwo(): void - { - // use $this->someServiceMock - } -} -CODE_SAMPLE - , - <<<'CODE_SAMPLE' -use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; - -#[AllowMockObjectsWithoutExpectations] -final class SomeTest extends TestCase -{ - private \PHPUnit\Framework\MockObject\MockObject $someServiceMock; - - protected function setUp(): void - { - $this->someServiceMock = $this->createMock(SomeService::class); - } - - public function testOne(): void - { - $this->someServiceMock->expects($this->once()) - ->method('someMethod') - ->willReturn('someValue'); - } - - public function testTwo(): void - { - $this->someServiceMock->expects($this->once()) - ->method('someMethod') - ->willReturn('anotherValue'); - } -} -CODE_SAMPLE - ), - ] - ); - } - - /** - * @return array> - */ - public function getNodeTypes(): array - { - return [Class_::class]; - } - - /** - * @param Class_ $node - */ - public function refactor(Node $node): ?Node - { - throw new ShouldNotHappenException(sprintf( - '"%s" is deprecated, as the attribute only silences the notice. Add the missing expects() to the test methods that use the mock instead.', - self::class, - )); - } -}