You are here

protected function MockGraphQLPluginTrait::mockUnion in GraphQL 8.3

Mock a GraphQL union.

Parameters

string $id: The union id.

array $definition: The plugin definition. Will be merged with the union defaults.

Return value

\PHPUnit\Framework\MockObject\MockObject The union mock object.

1 call to MockGraphQLPluginTrait::mockUnion()
TestFrameworkTest::testUnionMock in tests/src/Kernel/Framework/TestFrameworkTest.php
Test union mocks.

File

tests/src/Traits/MockGraphQLPluginTrait.php, line 561

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function mockUnion($id, array $definition, $builder = NULL) {
  $definition = $this
    ->getTypeSystemPluginDefinition(GraphQLUnionType::class, $definition + [
    'id' => $id,
    'class' => UnionTypePluginBase::class,
    'mock_factory' => 'mockUnionFactory',
  ]);
  $this->graphQLPlugins[UnionTypePluginBase::class][$id] = [
    'definition' => $definition,
    'builder' => $builder,
  ];
}