Skip to content

Commit e0918cc

Browse files
committed
Added leaking cache metadata regression tests.
1 parent 13bbe7d commit e0918cc

2 files changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Drupal\Tests\graphql_core\Kernel\Context;
4+
5+
use Drupal\node\Entity\Node;
6+
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
7+
8+
/**
9+
* Test full stack retrieval of a node context.
10+
*/
11+
class NodeContextTest extends GraphQLContentTestBase {
12+
13+
/**
14+
* Regression test for unhandled logic exceptions.
15+
*
16+
* Leaking cache metadata.
17+
*/
18+
public function testNodeContext() {
19+
$nodeId = Node::create([
20+
'title' => 'Test',
21+
'type' => 'test',
22+
])->save();
23+
24+
$query = <<<GQL
25+
query (\$path: String!) {
26+
route(path: \$path) {
27+
... on InternalUrl {
28+
nodeContext {
29+
entityLabel
30+
}
31+
}
32+
}
33+
}
34+
GQL;
35+
36+
$this->query($query, ['path' => '/node/' . $nodeId]);
37+
}
38+
39+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Drupal\Tests\graphql_core\Kernel\Context;
4+
5+
use Drupal\node\Entity\Node;
6+
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
7+
8+
/**
9+
* Fetch node revisions.
10+
*/
11+
class EntityRevisionsTest extends GraphQLContentTestBase {
12+
13+
/**
14+
* Regression test for unhandled logic exceptions.
15+
*
16+
* Leaking cache metadata.
17+
*/
18+
public function testNodeContext() {
19+
$node = Node::create([
20+
'title' => 'Test',
21+
'type' => 'test',
22+
]);
23+
24+
$nodeId = $node->save();
25+
$draft = $this->getNewDraft($node);
26+
$draft->save();
27+
28+
29+
$query = <<<GQL
30+
query (\$path: String!) {
31+
route(path: \$path) {
32+
... on EntityCanonicalUrl {
33+
entity {
34+
... on EntityRevisionable {
35+
entityRevisions {
36+
count
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
GQL;
44+
45+
$this->query($query, ['path' => '/node/' . $nodeId]);
46+
}
47+
48+
}

0 commit comments

Comments
 (0)