diff --git a/tests/unit/Framework/MockObject/Creation/CreatePartialMockTest.php b/tests/unit/Framework/MockObject/Creation/CreatePartialMockTest.php index 0929a7215ab..2cdb80461e6 100644 --- a/tests/unit/Framework/MockObject/Creation/CreatePartialMockTest.php +++ b/tests/unit/Framework/MockObject/Creation/CreatePartialMockTest.php @@ -12,6 +12,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Medium; use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException; use PHPUnit\Framework\TestCase; use PHPUnit\TestFixture\MockObject\ExtendableClass; use ReflectionProperty; @@ -32,6 +33,14 @@ public function testCreatesPartialMockObjectForExtendableClass(): void $this->assertTrue($mock->doSomething()); } + public function testCannotCreatePartialMockObjectForExtendableClassWithDuplicateMethods(): void + { + $this->expectException(DuplicateMethodException::class); + $this->expectExceptionMessage('Cannot double using a method list that contains duplicates: "doSomethingElse, doSomethingElse" (duplicate: "doSomethingElse")'); + + $this->createPartialMock(ExtendableClass::class, ['doSomethingElse', 'doSomethingElse']); + } + public function testMethodOfPartialMockThatIsNotConfigurableCannotBeConfigured(): void { $mock = $this->createPartialMock(ExtendableClass::class, ['doSomethingElse']);