Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions tests/Unit/AutomatedPersistedQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ public function testPersistedQueryNotFound(): void

public function testPersistedQueryFound(): void
{
$hash = hash('sha256', trim($this->queries['examples']));

// run query and persist

$response = $this->call('GET', '/graphql', [
'query' => trim($this->queries['examples']),
'extensions' => [
'persistedQuery' => [
'version' => 1,
'sha256Hash' => hash('sha256', trim($this->queries['examples'])),
'sha256Hash' => $hash,
],
],
]);
Expand All @@ -111,13 +113,13 @@ public function testPersistedQueryFound(): void
self::assertArrayHasKey('data', $content);
self::assertEquals(['examples' => $this->data], $content['data']);

// run persisted query
// run persisted query using POST

$response = $this->call('GET', '/graphql', [
$response = $this->call('POST', '/graphql', [
'extensions' => [
'persistedQuery' => [
'version' => 1,
'sha256Hash' => hash('sha256', trim($this->queries['examples'])),
'sha256Hash' => $hash,
],
],
]);
Expand All @@ -128,6 +130,17 @@ public function testPersistedQueryFound(): void

self::assertArrayHasKey('data', $content);
self::assertEquals(['examples' => $this->data], $content['data']);

// run persisted query using GET

$response = $this->call('GET', '/graphql?extensions={"persistedQuery":{"version":1,"sha256Hash":"' . $hash . '"}}');

self::assertEquals(200, $response->getStatusCode());

$content = $response->json();

self::assertArrayHasKey('data', $content);
self::assertEquals(['examples' => $this->data], $content['data']);
}

// This test demonstrates we don't actually check the 'version'
Expand Down