File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
tests/unit/Framework/MockObject/Creation Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 20
20
use PHPUnit \Framework \Attributes \Group ;
21
21
use PHPUnit \Framework \Attributes \Medium ;
22
22
use PHPUnit \Framework \Attributes \TestDox ;
23
+ use PHPUnit \Framework \MockObject \Generator \DuplicateMethodException ;
23
24
use PHPUnit \Framework \MockObject \Generator \NameAlreadyInUseException ;
24
25
use PHPUnit \Framework \TestCase ;
25
26
use PHPUnit \TestFixture \MockObject \AbstractClass ;
28
29
use PHPUnit \TestFixture \MockObject \TraitWithConcreteAndAbstractMethod ;
29
30
30
31
#[CoversClass(MockBuilder::class)]
32
+ #[CoversClass(DuplicateMethodException::class)]
31
33
#[CoversClass(NameAlreadyInUseException::class)]
32
34
#[CoversClass(CannotUseAddMethodsException::class)]
33
35
#[Group('test-doubles ' )]
@@ -82,6 +84,16 @@ public function testCannotCreateMockObjectForExtendableClassAddingMethodsToItTha
82
84
->getMock ();
83
85
}
84
86
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
+
85
97
#[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class ' )]
86
98
public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods (): void
87
99
{
You can’t perform that action at this time.
0 commit comments