You are here

protected function MockGraphQLPluginTrait::mockMutation in GraphQL 8.3

Mock a GraphQL mutation.

Parameters

string $id: The mutation id.

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

mixed|null $result: A result for this mutation. Can be a value or a callback. If omitted, no resolve method mock will be attached.

Return value

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

6 calls to MockGraphQLPluginTrait::mockMutation()
EntityMutationTest::testCreateEntityMutation in modules/graphql_core/tests/src/Kernel/EntityMutation/EntityMutationTest.php
Test entity creation.
EntityMutationTest::testCreateEntityMutationViolation in modules/graphql_core/tests/src/Kernel/EntityMutation/EntityMutationTest.php
Test entity creation violations.
EntityMutationTest::testDeleteEntityMutation in modules/graphql_core/tests/src/Kernel/EntityMutation/EntityMutationTest.php
Test entity deletion.
EntityMutationTest::testUpdateEntityMutation in modules/graphql_core/tests/src/Kernel/EntityMutation/EntityMutationTest.php
Test entity updates.
TestFrameworkTest::testMutationMock in tests/src/Kernel/Framework/TestFrameworkTest.php
Test mutation mocking.

... See full list

File

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

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function mockMutation($id, array $definition, $result = NULL, $builder = NULL) {
  $definition = $this
    ->getTypeSystemPluginDefinition(GraphQLMutation::class, $definition + [
    'id' => $id,
    'class' => MutationPluginBase::class,
    'mock_factory' => 'mockMutationFactory',
  ]);
  $this->graphQLPlugins[MutationPluginBase::class][$id] = [
    'definition' => $definition,
    'result' => $result,
    'builder' => $builder,
  ];
}