Skip to content

Commit

Permalink
Validate duplicate registered type
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Oct 20, 2021
1 parent a033156 commit 8418909
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Unit/Schema/Types/LaravelEnumTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

0 comments on commit 8418909

Please sign in to comment.