You are here

public function OverrideTypeTest::testOverriddenTypes in GraphQL 8.3

Test if the schema is created properly.

File

tests/src/Kernel/Extension/OverrideTypeTest.php, line 22

Class

OverrideTypeTest
Test plugin based schema generation.

Namespace

Drupal\Tests\graphql\Kernel\Extension

Code

public function testOverriddenTypes() {
  $vehicles = [
    [
      'type' => 'Car',
      'wheels' => 4,
      'engine' => 'fuel',
    ],
    [
      '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('fancy_garage.gql');
  $this
    ->assertResults($query, [], [
    'garage' => [
      0 => [
        'wheels' => 4,
        'type' => 'Car',
        'engine' => 'fuel',
      ],
      1 => [
        'wheels' => 3,
        'gadgets' => [
          'Phone charger',
          'GPS',
          'Coffee machine',
        ],
        'type' => 'Bike',
        'gears' => 21,
      ],
    ],
  ], $this
    ->defaultCacheMetaData());
}