Skip to content

Commit f01c941

Browse files
Add test
1 parent 93bf190 commit f01c941

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use PHPUnit\Framework\Attributes\Group;
2121
use PHPUnit\Framework\Attributes\Medium;
2222
use PHPUnit\Framework\Attributes\TestDox;
23+
use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException;
2324
use PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException;
2425
use PHPUnit\Framework\TestCase;
2526
use PHPUnit\TestFixture\MockObject\AbstractClass;
@@ -28,6 +29,7 @@
2829
use PHPUnit\TestFixture\MockObject\TraitWithConcreteAndAbstractMethod;
2930

3031
#[CoversClass(MockBuilder::class)]
32+
#[CoversClass(DuplicateMethodException::class)]
3133
#[CoversClass(NameAlreadyInUseException::class)]
3234
#[CoversClass(CannotUseAddMethodsException::class)]
3335
#[Group('test-doubles')]
@@ -82,6 +84,16 @@ public function testCannotCreateMockObjectForExtendableClassAddingMethodsToItTha
8284
->getMock();
8385
}
8486

87+
#[TestDox('addMethods() cannot be used to configure an additional method for the mock object class multiple times using the same name')]
88+
public function testCannotCreateMockObjectForExtendableClassAddingMultipleMethodsWithSameNameToIt(): void
89+
{
90+
$this->expectException(DuplicateMethodException::class);
91+
92+
$this->getMockBuilder(ExtendableClass::class)
93+
->addMethods(['additionalMethod', 'additionalMethod'])
94+
->getMock();
95+
}
96+
8597
#[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class')]
8698
public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods(): void
8799
{

0 commit comments

Comments
 (0)