Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
graphql
Commits
1c03feae
Commit
1c03feae
authored
Feb 03, 2021
by
pmelab
Browse files
refactor: use `assertResults` with cache metadata checks instead
parent
4b2948ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
examples/graphql_examples/tests/src/Kernel/Schema/ExampleSchemaTest.php
View file @
1c03feae
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\Tests\graphql_example\Kernel
;
use
Drupal\Core\Cache\CacheableMetadata
;
use
Drupal\node\Entity\Node
;
use
Drupal\node\Entity\NodeType
;
use
Drupal\Tests\graphql\Kernel\GraphQLTestBase
;
...
...
@@ -69,20 +70,19 @@ class ExampleSchemaTest extends GraphQLTestBase {
])
->
save
();
// Execute the query and run assertions against its response content.
$response
=
$this
->
query
(
'{ articles { total, items { title, author } } }'
);
$content
=
json_decode
(
$response
->
getContent
(),
TRUE
);
$this
->
assertEquals
([
'data'
=>
[
'articles'
=>
[
'total'
=>
3
,
'items'
=>
[
[
'title'
=>
'ONE'
,
'author'
=>
'A'
],
[
'title'
=>
'TWO'
,
'author'
=>
'B'
],
[
'title'
=>
'THREE'
,
'author'
=>
'A'
],
],
$this
->
assertResults
(
'{ articles { total, items { title, author } } }'
,
[],
[
'articles'
=>
[
'total'
=>
3
,
'items'
=>
[
[
'title'
=>
'ONE'
,
'author'
=>
'A'
],
[
'title'
=>
'TWO'
,
'author'
=>
'B'
],
[
'title'
=>
'THREE'
,
'author'
=>
'A'
],
],
],
],
$content
);
],
$this
->
defaultCacheMetaData
()
->
addCacheContexts
([
'user.node_grants:view'
])
->
addCacheTags
([
'node:1'
,
'node:2'
,
'node:3'
,
'node_list'
,
'user:3'
,
'user:4'
])
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment