You are here

protected function MockGraphQLPluginTrait::mockMutationFactory in GraphQL 8.3

1 method overrides MockGraphQLPluginTrait::mockMutationFactory()
EntityMutationTest::mockMutationFactory in modules/graphql_core/tests/src/Kernel/EntityMutation/EntityMutationTest.php

File

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

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function mockMutationFactory($definition, $result = NULL, $builder = NULL) {
  $mutation = $this
    ->getMockBuilder(MutationPluginBase::class)
    ->setConstructorArgs([
    [],
    $definition['id'],
    $definition,
  ])
    ->setMethods([
    'resolve',
  ])
    ->getMock();
  if (isset($result)) {
    $mutation
      ->expects(static::any())
      ->method('resolve')
      ->with(static::anything(), static::anything(), static::anything(), static::anything())
      ->will($this
      ->toBoundPromise($result, $mutation));
  }
  if (is_callable($builder)) {
    $builder($mutation);
  }
  return $mutation;
}