From 31671ffe2ff29e2daa35cc03b078ff5b7680b790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 3 Feb 2026 21:58:23 +0100 Subject: [PATCH] Use stubs when appropriate This addresses some PHPunit notices we have. --- tests/InflectorTest.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/InflectorTest.php b/tests/InflectorTest.php index 55a5273..dc39147 100644 --- a/tests/InflectorTest.php +++ b/tests/InflectorTest.php @@ -7,15 +7,15 @@ namespace Doctrine\Tests\Inflector; use Doctrine\Inflector\Inflector; use Doctrine\Inflector\WordInflector; use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\MockObject\Stub; use PHPUnit\Framework\TestCase; class InflectorTest extends TestCase { - /** @var WordInflector&MockObject */ + /** @var WordInflector&Stub */ private $singularInflector; - /** @var WordInflector&MockObject */ + /** @var WordInflector&Stub */ private $pluralInflector; /** @var Inflector */ @@ -118,28 +118,35 @@ class InflectorTest extends TestCase public function testPluralize(): void { - $this->pluralInflector->expects(self::once()) + $pluralInflector = $this->createMock(WordInflector::class); + + $pluralInflector->expects(self::once()) ->method('inflect') ->with('in') ->willReturn('out'); - self::assertSame('out', $this->inflector->pluralize('in')); + $inflector = new Inflector($this->singularInflector, $pluralInflector); + + self::assertSame('out', $inflector->pluralize('in')); } public function testSingularize(): void { - $this->singularInflector->expects(self::once()) + $singularInflector = $this->createMock(WordInflector::class); + + $inflector = new Inflector($singularInflector, $this->pluralInflector); + $singularInflector->expects(self::once()) ->method('inflect') ->with('in') ->willReturn('out'); - self::assertSame('out', $this->inflector->singularize('in')); + self::assertSame('out', $inflector->singularize('in')); } protected function setUp(): void { - $this->singularInflector = $this->createMock(WordInflector::class); - $this->pluralInflector = $this->createMock(WordInflector::class); + $this->singularInflector = self::createStub(WordInflector::class); + $this->pluralInflector = self::createStub(WordInflector::class); $this->inflector = new Inflector($this->singularInflector, $this->pluralInflector); }