Skip to content
Draft
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
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();
}
}