Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Rename exception #107

Merged
merged 1 commit into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

namespace Ergebnis\FactoryBot\Exception;

final class EntityDefinitionUnavailable extends \RuntimeException implements Exception
final class EntityDefinitionNotRegistered extends \RuntimeException implements Exception
{
public static function for(string $className): self
{
return new self(\sprintf(
'An entity definition for class name "%s" is not available.',
'An entity definition for class name "%s" has not been registered.',
$className
));
}
Expand Down
4 changes: 2 additions & 2 deletions src/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function defineEntity(string $className, array $fieldDefinitions = [], ?\
* @param string $className
* @param array<string, mixed> $fieldOverrides
*
* @throws Exception\EntityDefinitionUnavailable
* @throws Exception\EntityDefinitionNotRegistered
* @throws Exception\InvalidFieldNames
*/
public function get(string $className, array $fieldOverrides = []): object
Expand All @@ -169,7 +169,7 @@ public function get(string $className, array $fieldOverrides = []): object
}

if (!\array_key_exists($className, $this->entityDefinitions)) {
throw Exception\EntityDefinitionUnavailable::for($className);
throw Exception\EntityDefinitionNotRegistered::for($className);
}

/** @var EntityDefinition $entityDefinition */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
/**
* @internal
*
* @covers \Ergebnis\FactoryBot\Exception\EntityDefinitionUnavailable
* @covers \Ergebnis\FactoryBot\Exception\EntityDefinitionNotRegistered
*/
final class EntityDefinitionUnavailableTest extends Framework\TestCase
final class EntityDefinitionNotRegisteredTest extends Framework\TestCase
{
public function testForReturnsException(): void
{
$className = 'foo';

$exception = Exception\EntityDefinitionUnavailable::for($className);
$exception = Exception\EntityDefinitionNotRegistered::for($className);

$message = \sprintf(
'An entity definition for class name "%s" is not available.',
'An entity definition for class name "%s" has not been registered.',
$className
);

Expand Down
6 changes: 3 additions & 3 deletions test/Unit/FixtureFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @uses \Ergebnis\FactoryBot\EntityDefinition
* @uses \Ergebnis\FactoryBot\Exception\EntityDefinitionAlreadyRegistered
* @uses \Ergebnis\FactoryBot\Exception\EntityDefinitionUnavailable
* @uses \Ergebnis\FactoryBot\Exception\EntityDefinitionNotRegistered
* @uses \Ergebnis\FactoryBot\Exception\InvalidCount
* @uses \Ergebnis\FactoryBot\Exception\InvalidFieldNames
*/
Expand Down Expand Up @@ -117,9 +117,9 @@ public function testGetThrowsEntityDefinitionUnavailableWhenDefinitionIsUnavaila

$fixtureFactory = new FixtureFactory($entityManager);

$this->expectException(Exception\EntityDefinitionUnavailable::class);
$this->expectException(Exception\EntityDefinitionNotRegistered::class);
$this->expectExceptionMessage(\sprintf(
'An entity definition for class name "%s" is not available.',
'An entity definition for class name "%s" has not been registered.',
$className
));

Expand Down