Skip to content

Commit bd3261a

Browse files
committed
GraphQL: Test property type Object without class
1 parent b08731f commit bd3261a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/GraphQl/Type/SchemaBuilderTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,37 @@ public function testGetSchema(bool $paginationEnabled)
209209
);
210210
}
211211

212+
/**
213+
* Tests that the GraphQL SchemaBuilder supports an edge case where a property is typed as an Type::BUILTIN_TYPE_OBJECT but has no class related.
214+
*/
215+
public function testObjectTypeWithoutClass()
216+
{
217+
$propertyMetadataMockBuilder = function ($builtinType, $resourceClassName) {
218+
return new PropertyMetadata(
219+
new Type(
220+
$builtinType
221+
),
222+
"{$builtinType}Description",
223+
true,
224+
true,
225+
null,
226+
null,
227+
null
228+
);
229+
};
230+
231+
$mockedSchemaBuilder = $this->createSchemaBuilder($propertyMetadataMockBuilder, false);
232+
$this->assertEquals([
233+
'node',
234+
'shortName1',
235+
'shortName1s',
236+
'shortName2',
237+
'shortName2s',
238+
'shortName3',
239+
'shortName3s',
240+
], array_keys($mockedSchemaBuilder->getSchema()->getConfig()->getQuery()->getFields()));
241+
}
242+
212243
public function paginationProvider(): array
213244
{
214245
return [

0 commit comments

Comments
 (0)