You are here

public function TypeTest::testQuery in GraphQL 8.3

Test if the schema is created properly.

File

tests/src/Kernel/Extension/TypeTest.php, line 21

Class

TypeTest
Test plugin based schema generation.

Namespace

Drupal\Tests\graphql\Kernel\Extension

Code

public function testQuery() {
  $vehicles = [
    [
      'type' => 'Car',
      'wheels' => 4,
      'engine' => 'fuel',
    ],
    [
      'type' => 'Car',
      'wheels' => 4,
      'engine' => 'diesel',
    ],
    [
      'type' => 'Bike',
      'wheels' => 2,
      'gears' => 21,
    ],
  ];
  $prophecy = $this
    ->prophesize(GarageInterface::class);
  $prophecy
    ->getVehicles()
    ->willReturn($vehicles);
  $this->container
    ->set('graphql_test.garage', $prophecy
    ->reveal());
  $query = $this
    ->getQueryFromFile('garage.gql');
  $this
    ->assertResults($query, [], [
    'garage' => $vehicles,
  ], $this
    ->defaultCacheMetaData());
}