You are here

public function MutationTest::testMutationQuery in GraphQL 8.3

Test if the schema is created properly.

File

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

Class

MutationTest
Test a simple mutation.

Namespace

Drupal\Tests\graphql\Kernel\Extension

Code

public function testMutationQuery() {
  $car = [
    'engine' => 'electric',
  ];
  $prophecy = $this
    ->prophesize(GarageInterface::class);
  $prophecy
    ->insertVehicle($car)
    ->willReturn([
    'type' => 'Car',
    'wheels' => 4,
    'engine' => 'electric',
  ])
    ->shouldBeCalled();
  $this->container
    ->set('graphql_test.garage', $prophecy
    ->reveal());
  $query = $this
    ->getQueryFromFile('buy_car.gql');
  $this
    ->assertResults($query, [
    'car' => $car,
  ], [
    'buyCar' => [
      '__typename' => 'Car',
    ],
  ], $this
    ->defaultMutationCacheMetaData());
}