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 15
15
use PHPUnit \Framework \Attributes \Group ;
16
16
use PHPUnit \Framework \Attributes \Medium ;
17
17
use PHPUnit \Framework \Attributes \TestDox ;
18
+ use PHPUnit \Framework \MockObject \Generator \ClassAlreadyExistsException ;
18
19
use PHPUnit \Framework \TestCase ;
19
20
use PHPUnit \TestFixture \MockObject \AbstractClass ;
20
21
use PHPUnit \TestFixture \MockObject \ExtendableClass ;
21
22
use PHPUnit \TestFixture \MockObject \InterfaceWithReturnTypeDeclaration ;
22
23
use PHPUnit \TestFixture \MockObject \TraitWithConcreteAndAbstractMethod ;
23
24
24
25
#[CoversClass(MockBuilder::class)]
26
+ #[CoversClass(ClassAlreadyExistsException::class)]
25
27
#[CoversClass(CannotUseAddMethodsException::class)]
26
28
#[Group('test-doubles ' )]
27
29
#[Group('test-doubles/creation ' )]
@@ -41,6 +43,16 @@ public function testCanCreateMockObjectWithSpecifiedClassName(): void
41
43
$ this ->assertSame ($ className , $ double ::class);
42
44
}
43
45
46
+ #[TestDox('setMockClassName() cannot be used to configure the name of the mock object class when a class with that name already exists ' )]
47
+ public function testCannotCreateMockObjectWithSpecifiedClassNameWhenClassWithThatNameAlreadyExists (): void
48
+ {
49
+ $ this ->expectException (ClassAlreadyExistsException::class);
50
+
51
+ $ this ->getMockBuilder (InterfaceWithReturnTypeDeclaration::class)
52
+ ->setMockClassName (__CLASS__ )
53
+ ->getMock ();
54
+ }
55
+
44
56
#[TestDox('addMethods() can be used to configure an additional method for the mock object class when the original class does not have a method of the same name ' )]
45
57
public function testCanCreateMockObjectForExtendableClassWhileAddingMethodsToIt (): void
46
58
{
You can’t perform that action at this time.
0 commit comments