generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from ergebnis/fix/reject
Fix: Reject invalid field definition values
- Loading branch information
Showing
6 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2020 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/factory-bot | ||
*/ | ||
|
||
namespace Ergebnis\FactoryBot\Exception; | ||
|
||
use Ergebnis\FactoryBot\FieldDefinition; | ||
|
||
final class InvalidFieldDefinitions extends \RuntimeException implements Exception | ||
{ | ||
public static function values(): self | ||
{ | ||
return new self(\sprintf( | ||
'Field definitions need to be instances of "%s".', | ||
FieldDefinition::class | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2020 Andreas Möller | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE.md file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ergebnis/factory-bot | ||
*/ | ||
|
||
namespace Ergebnis\FactoryBot\Test\Unit\Exception; | ||
|
||
use Ergebnis\FactoryBot\Exception; | ||
use Ergebnis\FactoryBot\FieldDefinition; | ||
use Ergebnis\Test\Util\Helper; | ||
use PHPUnit\Framework; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @covers \Ergebnis\FactoryBot\Exception\InvalidFieldDefinitions | ||
*/ | ||
final class InvalidFieldDefinitionsTest extends Framework\TestCase | ||
{ | ||
use Helper; | ||
|
||
public function testFromClassNameCreatesException(): void | ||
{ | ||
$exception = Exception\InvalidFieldDefinitions::values(); | ||
|
||
$message = \sprintf( | ||
'Field definitions need to be instances of "%s".', | ||
FieldDefinition::class | ||
); | ||
|
||
self::assertSame($message, $exception->getMessage()); | ||
} | ||
} |