You are here

protected function MockGraphQLPluginTrait::mockEnumFactory in GraphQL 8.3

File

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

Class

MockGraphQLPluginTrait
Trait for mocking GraphQL type system plugins.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function mockEnumFactory($definition, $values = [], $builder = NULL) {
  $enum = $this
    ->getMockBuilder(EnumPluginBase::class)
    ->setConstructorArgs([
    [],
    $definition['id'],
    $definition,
  ])
    ->setMethods([
    'buildEnumValues',
  ])
    ->getMock();
  $enum
    ->expects(static::any())
    ->method('buildEnumValues')
    ->with($this
    ->anything())
    ->will($this
    ->toBoundPromise($values, $enum));
  if (is_callable($builder)) {
    $builder($enum);
  }
  return $enum;
}