|
21 | 21 | use PHPUnit\Framework\Attributes\Medium;
|
22 | 22 | use PHPUnit\Framework\Attributes\TestDox;
|
23 | 23 | use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException;
|
| 24 | +use PHPUnit\Framework\MockObject\Generator\InvalidMethodNameException; |
24 | 25 | use PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException;
|
25 | 26 | use PHPUnit\Framework\TestCase;
|
26 | 27 | use PHPUnit\TestFixture\MockObject\AbstractClass;
|
|
29 | 30 | use PHPUnit\TestFixture\MockObject\TraitWithConcreteAndAbstractMethod;
|
30 | 31 |
|
31 | 32 | #[CoversClass(MockBuilder::class)]
|
| 33 | +#[CoversClass(CannotUseAddMethodsException::class)] |
32 | 34 | #[CoversClass(DuplicateMethodException::class)]
|
| 35 | +#[CoversClass(InvalidMethodNameException::class)] |
33 | 36 | #[CoversClass(NameAlreadyInUseException::class)]
|
34 |
| -#[CoversClass(CannotUseAddMethodsException::class)] |
35 | 37 | #[Group('test-doubles')]
|
36 | 38 | #[Group('test-doubles/creation')]
|
37 | 39 | #[Group('test-doubles/mock-object')]
|
@@ -94,6 +96,16 @@ public function testCannotCreateMockObjectForExtendableClassAddingMultipleMethod
|
94 | 96 | ->getMock();
|
95 | 97 | }
|
96 | 98 |
|
| 99 | + #[TestDox('addMethods() cannot be used to configure an additional method for the mock object class with invalid name')] |
| 100 | + public function testCannotCreateMockObjectForExtendableClassAddingMethodToItWithInvalidName(): void |
| 101 | + { |
| 102 | + $this->expectException(InvalidMethodNameException::class); |
| 103 | + |
| 104 | + $this->getMockBuilder(ExtendableClass::class) |
| 105 | + ->addMethods(['1234']) |
| 106 | + ->getMock(); |
| 107 | + } |
| 108 | + |
97 | 109 | #[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class')]
|
98 | 110 | public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods(): void
|
99 | 111 | {
|
|
0 commit comments