diff --git a/tests/Unit/Schema/Types/LaravelEnumTypeTest.php b/tests/Unit/Schema/Types/LaravelEnumTypeTest.php index cec5ad2300..b40d5a7ec9 100644 --- a/tests/Unit/Schema/Types/LaravelEnumTypeTest.php +++ b/tests/Unit/Schema/Types/LaravelEnumTypeTest.php @@ -2,6 +2,7 @@ namespace Tests\Unit\Schema\Types; +use GraphQL\Error\InvariantViolation; use Nuwave\Lighthouse\Schema\TypeRegistry; use Nuwave\Lighthouse\Schema\Types\LaravelEnumType; use PHPUnit\Framework\Constraint\Callback; @@ -61,4 +62,24 @@ public function testReceivesEnumInstanceInternally(): void } '); } + + public function testValidatesDuplicateDefinition(): void + { + $this->typeRegistry->register( + new LaravelEnumType(AOrB::class) + ); + + $this->expectException(InvariantViolation::class); + $schema = $this->buildSchema(/** @lang GraphQL */ ' + type Query { + foo: ID + } + + enum AOrB { + A + B + } + '); + $schema->assertValid(); + } }