Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Apr 26, 2024
1 parent 547d314 commit b7e95f5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/unit/Framework/MockObject/Creation/MockBuilderTest.php
Expand Up @@ -15,13 +15,15 @@
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Medium;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\MockObject\Generator\ClassAlreadyExistsException;
use PHPUnit\Framework\TestCase;
use PHPUnit\TestFixture\MockObject\AbstractClass;
use PHPUnit\TestFixture\MockObject\ExtendableClass;
use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration;
use PHPUnit\TestFixture\MockObject\TraitWithConcreteAndAbstractMethod;

#[CoversClass(MockBuilder::class)]
#[CoversClass(ClassAlreadyExistsException::class)]
#[CoversClass(CannotUseAddMethodsException::class)]
#[Group('test-doubles')]
#[Group('test-doubles/creation')]
Expand All @@ -41,6 +43,16 @@ public function testCanCreateMockObjectWithSpecifiedClassName(): void
$this->assertSame($className, $double::class);
}

#[TestDox('setMockClassName() cannot be used to configure the name of the mock object class when a class with that name already exists')]
public function testCannotCreateMockObjectWithSpecifiedClassNameWhenClassWithThatNameAlreadyExists(): void
{
$this->expectException(ClassAlreadyExistsException::class);

$this->getMockBuilder(InterfaceWithReturnTypeDeclaration::class)
->setMockClassName(__CLASS__)
->getMock();
}

#[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')]
public function testCanCreateMockObjectForExtendableClassWhileAddingMethodsToIt(): void
{
Expand Down

0 comments on commit b7e95f5

Please sign in to comment.