generated from worksome/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #13 from worksome/feature/graphql-convertable-tests
tests: add tests for GraphQLConvertable concern
- Loading branch information
Showing
3 changed files
with
31 additions
and
4 deletions.
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
29 changes: 29 additions & 0 deletions
29
tests/Unit/Definition/Concerns/GraphQLConvertable/GraphQLConvertableTest.php
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Worksome\GraphQLHelpers\Tests\Unit\Definition\Concerns\GraphQLConvertable; | ||
|
||
use GraphQL\Type\Definition\Description; | ||
use Worksome\GraphQLHelpers\Definition\Concerns\GraphQLConvertable; | ||
|
||
#[Description('Dummy enum description')] | ||
enum DummyEnum | ||
{ | ||
use GraphQLConvertable; | ||
|
||
#[Description('PascalCase description')] | ||
case PascalCase; | ||
#[Description('SCREAMING_SNAKE_CASE description')] | ||
case SCREAMING_SNAKE_CASE; // phpcs:ignore | ||
#[Description('snake_case description')] | ||
case snake_case; // phpcs:ignore | ||
} | ||
|
||
it('can convert an enum to the correct case for GraphQL', function (DummyEnum $enum, string $graphQLValue) { | ||
expect($enum->toGraphQLValue())->toBe($graphQLValue); | ||
})->with([ | ||
[DummyEnum::PascalCase, 'PASCAL_CASE'], | ||
[DummyEnum::SCREAMING_SNAKE_CASE, 'SCREAMING_SNAKE_CASE'], | ||
[DummyEnum::snake_case, 'SNAKE_CASE'], | ||
]); |
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