protected function MockGraphQLPluginTrait::mockField in GraphQL 8.3
Mock a GraphQL field.
Parameters
string $id: The field id.
array $definition: The plugin definition. Will be merged with the field defaults.
mixed|null $result: A result for this field. Can be a value or a callback. If omitted, no resolve method mock will be attached.
callable|null $builder: A builder callback to modify the mock instance.
27 calls to MockGraphQLPluginTrait::mockField()
- BufferedFieldTest::testBatchedFields in tests/
src/ Kernel/ Framework/ BufferedFieldTest.php - Test if the schema is created properly.
- DisabledResultCacheTest::testDisabledCache in tests/
src/ Kernel/ Framework/ DisabledResultCacheTest.php - Test if disabling the result cache has the desired effect.
- DisabledSchemaCacheTest::testDisabledCacheWithCacheMetadata in tests/
src/ Kernel/ Framework/ DisabledSchemaCacheTest.php - Test disabled schema caching with cache metadata.
- DisabledSchemaCacheTest::testDisabledCacheWithoutCacheMetadata in tests/
src/ Kernel/ Framework/ DisabledSchemaCacheTest.php - Test disabled schema caching without cache metadata.
- GraphQLContentTestBase::mockNode in modules/
graphql_core/ tests/ src/ Kernel/ GraphQLContentTestBase.php - Mock a field that emits a test node.
File
- tests/
src/ Traits/ MockGraphQLPluginTrait.php, line 325
Class
- MockGraphQLPluginTrait
- Trait for mocking GraphQL type system plugins.
Namespace
Drupal\Tests\graphql\TraitsCode
protected function mockField($id, $definition, $result = NULL, $builder = NULL) {
$definition = $this
->getTypeSystemPluginDefinition(GraphQLField::class, $definition + [
'secure' => TRUE,
'id' => $id,
'class' => FieldPluginBase::class,
'mock_factory' => 'mockFieldFactory',
]);
$this->graphQLPlugins[FieldPluginBase::class][$id] = [
'definition' => $definition,
'result' => $result,
'builder' => $builder,
];
}