ResultTest.php in GraphQL 8.4
File
tests/src/Kernel/Framework/ResultTest.php
View source
<?php
namespace Drupal\Tests\graphql\Kernel\Framework;
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
class ResultTest extends GraphQLTestBase {
protected function setUp() : void {
parent::setUp();
$schema = <<<GQL
schema {
query: Query
}
type Query {
root: String
}
GQL;
$this
->setUpSchema($schema);
$this
->mockResolver('Query', 'root', 'test');
}
public function testQuery() : void {
$result = $this
->query('query { root }');
$this
->assertSame(200, $result
->getStatusCode());
$this
->assertSame([
'data' => [
'root' => 'test',
],
], json_decode($result
->getContent(), TRUE));
}
public function testBatchedQueries() : void {
$result = $this
->batchedQueries([
[
'query' => 'query { root } ',
],
[
'query' => 'query { root }',
],
]);
$this
->assertSame(200, $result
->getStatusCode());
$this
->assertSame([
[
'data' => [
'root' => 'test',
],
],
[
'data' => [
'root' => 'test',
],
],
], json_decode($result
->getContent(), TRUE));
}
}