Skip to content

Commit 0c843b0

Browse files
Add test
1 parent cac7631 commit 0c843b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/unit/Framework/MockObject/Creation/CreatePartialMockTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use PHPUnit\Framework\Attributes\Group;
1313
use PHPUnit\Framework\Attributes\Medium;
1414
use PHPUnit\Framework\Attributes\TestDox;
15+
use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException;
1516
use PHPUnit\Framework\TestCase;
1617
use PHPUnit\TestFixture\MockObject\ExtendableClass;
1718
use ReflectionProperty;
@@ -32,6 +33,14 @@ public function testCreatesPartialMockObjectForExtendableClass(): void
3233
$this->assertTrue($mock->doSomething());
3334
}
3435

36+
public function testCannotCreatePartialMockObjectForExtendableClassWithDuplicateMethods(): void
37+
{
38+
$this->expectException(DuplicateMethodException::class);
39+
$this->expectExceptionMessage('Cannot double using a method list that contains duplicates: "doSomethingElse, doSomethingElse" (duplicate: "doSomethingElse")');
40+
41+
$this->createPartialMock(ExtendableClass::class, ['doSomethingElse', 'doSomethingElse']);
42+
}
43+
3544
public function testMethodOfPartialMockThatIsNotConfigurableCannotBeConfigured(): void
3645
{
3746
$mock = $this->createPartialMock(ExtendableClass::class, ['doSomethingElse']);

0 commit comments

Comments
 (0)