You are here

protected function MockGraphQLPluginTrait::mockType in GraphQL 8.3

Mock a GraphQL type.

Parameters

string $id: The type id.

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

mixed|null $applies: A result for the types "applies" method. Defaults to `TRUE`.

Return value

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

7 calls to MockGraphQLPluginTrait::mockType()
BufferedFieldTest::testBatchedFields in tests/src/Kernel/Framework/BufferedFieldTest.php
Test if the schema is created properly.
LanguageContextTest::setUp in tests/src/Kernel/Framework/LanguageContextTest.php
ResolveContextTest::testContextualArguments in tests/src/Kernel/Extension/ResolveContextTest.php
Test manual context handling.
ResolveContextTest::testResolveContext in tests/src/Kernel/Extension/ResolveContextTest.php
Test manual context handling.
TestFrameworkTest::testInterfaceMock in tests/src/Kernel/Framework/TestFrameworkTest.php
Test interface mocking.

... See full list

File

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

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function mockType($id, array $definition, $applies = TRUE, $builder = NULL) {
  $definition = $this
    ->getTypeSystemPluginDefinition(GraphQLType::class, $definition + [
    'id' => $id,
    'class' => TypePluginBase::class,
    'mock_factory' => 'mockTypeFactory',
  ]);
  $this->graphQLPlugins[TypePluginBase::class][$id] = [
    'definition' => $definition,
    'applies' => $applies,
    'builder' => $builder,
  ];
}