Skip to content

Commit 3874ac2

Browse files
Add test
1 parent 260584e commit 3874ac2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPUnit\Framework\Attributes\Medium;
2222
use PHPUnit\Framework\Attributes\TestDox;
2323
use PHPUnit\Framework\MockObject\Generator\DuplicateMethodException;
24+
use PHPUnit\Framework\MockObject\Generator\InvalidMethodNameException;
2425
use PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException;
2526
use PHPUnit\Framework\TestCase;
2627
use PHPUnit\TestFixture\MockObject\AbstractClass;
@@ -29,9 +30,10 @@
2930
use PHPUnit\TestFixture\MockObject\TraitWithConcreteAndAbstractMethod;
3031

3132
#[CoversClass(MockBuilder::class)]
33+
#[CoversClass(CannotUseAddMethodsException::class)]
3234
#[CoversClass(DuplicateMethodException::class)]
35+
#[CoversClass(InvalidMethodNameException::class)]
3336
#[CoversClass(NameAlreadyInUseException::class)]
34-
#[CoversClass(CannotUseAddMethodsException::class)]
3537
#[Group('test-doubles')]
3638
#[Group('test-doubles/creation')]
3739
#[Group('test-doubles/mock-object')]
@@ -94,6 +96,16 @@ public function testCannotCreateMockObjectForExtendableClassAddingMultipleMethod
9496
->getMock();
9597
}
9698

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+
97109
#[TestDox('getMockForAbstractClass() can be used to create a mock object for an abstract class')]
98110
public function testCreatesMockObjectForAbstractClassAndAllowsConfigurationOfAbstractMethods(): void
99111
{

0 commit comments

Comments
 (0)