public function TestFrameworkTest::testFieldMock in GraphQL 8.3
Same name and namespace in other branches
- 8.4 tests/src/Kernel/Framework/TestFrameworkTest.php \Drupal\Tests\graphql\Kernel\Framework\TestFrameworkTest::testFieldMock()
Test mocked fields.
File
- tests/
src/ Kernel/ Framework/ TestFrameworkTest.php, line 22
Class
- TestFrameworkTest
- Test the test framework.
Namespace
Drupal\Tests\graphql\Kernel\FrameworkCode
public function testFieldMock() {
$this
->mockField('root', [
'name' => 'root',
'type' => 'String',
'response_cache_tags' => [
'my_tag',
],
], function () {
(yield (new CacheableValue('test'))
->mergeCacheMaxAge(42));
});
$metadata = $this
->defaultCacheMetaData();
$metadata
->setCacheMaxAge(42);
$metadata
->addCacheTags([
'my_tag',
]);
$schema = $this
->introspect();
$this
->assertArraySubset([
'types' => [
'Query' => [
'fields' => [
'root' => [
'name' => 'root',
'type' => [
'kind' => 'SCALAR',
'name' => 'String',
],
],
],
],
],
], $schema);
$this
->assertResults('{ root }', [], [
'root' => 'test',
], $metadata);
}