for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Drupal\Tests\graphql_core\Kernel\EntityQuery;
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
/**
* Test entity query support in GraphQL.
*
* @group graphql_core
*/
class EntityQueryTest extends GraphQLContentTestBase {
* {@inheritdoc}
protected function setUp() {
parent::setUp();
$this->createContentType(['type' => 'a']);
$this->createContentType(['type' => 'b']);
}
* Test that entity queries work.
public function testEntityQuery() {
$a = $this->createNode([
'title' => 'Node A',
'type' => 'a',
]);
$b = $this->createNode([
'title' => 'Node B',
$c = $this->createNode([
'title' => 'Node C',
$d = $this->createNode([
'title' => 'Node D',
'type' => 'b',
$a->save();
$b->save();
$c->save();
$d->save();
// TODO: Check cache metadata.
$metadata = $this->defaultCacheMetaData();
$metadata->addCacheContexts(['user.node_grants:view']);
$metadata->addCacheTags([
'entity_bundles',
'entity_field_info',
'entity_types',
'node:' . $a->id(),
'node:' . $b->id(),
'node:' . $c->id(),
'node:' . $d->id(),
'node_list',
$this->assertResults($this->getQueryFromFile('entity_query.gql'), [], [
'a' => [
'entities' => [
['uuid' => $a->uuid()],
['uuid' => $b->uuid()],
['uuid' => $c->uuid()],
],
'count' => 3,
'b' => [
['uuid' => $d->uuid()],
'count' => 1,
'limit' => [
'offset' => [
'offset_limit' => [
'all_nodes' => [
'count' => 4,
], $metadata);