protected function MockingTrait::mockSchema in GraphQL 8.4
Mock a schema instance.
Parameters
string $id: The schema id.
string $schema: The schema.
\Drupal\graphql\Plugin\SchemaExtensionPluginInterface[] $extensions: An array of schema extension plugins.
1 call to MockingTrait::mockSchema()
- MockingTrait::setUpSchema in tests/
src/ Traits/ MockingTrait.php - Setup server with schema.
File
- tests/
src/ Traits/ MockingTrait.php, line 126
Class
- MockingTrait
- Contains helpers for setting up mock servers and schemas for testing.
Namespace
Drupal\Tests\graphql\TraitsCode
protected function mockSchema($id, $schema, array $extensions = []) : void {
/** @var \PHPUnit\Framework\MockObject\MockObject $extensionManager */
$extensionManager = $this
->getMockBuilder(SchemaExtensionPluginManager::class)
->disableOriginalConstructor()
->setMethods([
'getExtensions',
])
->getMock();
$extensionManager
->expects(static::any())
->method('getExtensions')
->willReturn($extensions);
$this->schema = $this
->getMockBuilder(SdlSchemaPluginBase::class)
->setConstructorArgs([
[],
$id,
[],
$this->container
->get('cache.graphql.ast'),
$this->container
->get('module_handler'),
$extensionManager,
[
'development' => FALSE,
],
])
->setMethods([
'getSchemaDefinition',
'getResolverRegistry',
])
->getMockForAbstractClass();
$this->schema
->expects(static::any())
->method('getSchemaDefinition')
->willReturn($schema);
$this->registry = new ResolverRegistry();
$this->schema
->expects($this
->any())
->method('getResolverRegistry')
->willReturn($this->registry);
}