public function testProhibitsPuttingNonObjectTypesInUnions()
{
$int = Type::int();
$badUnionTypes = [$int, new NonNull($int), new ListOfType($int), $this->interfaceType, $this->unionType, $this->enumType, $this->inputObjectType];
Config::enableValidation();
foreach ($badUnionTypes as $type) {
try {
new UnionType(['name' => 'BadUnion', 'types' => [$type]]);
$this->fail('Expected exception not thrown');
} catch (\Exception $e) {
$this->assertSame('Expecting callable or instance of GraphQL\\Type\\Definition\\ObjectType at "types:0", but got "' . get_class($type) . '"', $e->getMessage());
}
}
Config::disableValidation();
}