You are here

public function RouteEntityTest::testRouteEntity in GraphQL 8.3

File

modules/graphql_core/tests/src/Kernel/Routing/RouteEntityTest.php, line 14

Class

RouteEntityTest
Test file attachments.

Namespace

Drupal\Tests\graphql_core\Kernel\Routing

Code

public function testRouteEntity() {
  $node = $this
    ->createNode([
    'title' => 'Node A',
    'type' => 'test',
  ]);
  $node
    ->save();
  $node
    ->addTranslation('fr', [
    'title' => 'Node A french',
  ])
    ->save();
  $query = $this
    ->getQueryFromFile('route_entity.gql');
  $vars = [
    'path' => '/node/' . $node
      ->id(),
  ];
  $metadata = $this
    ->defaultCacheMetaData();
  $metadata
    ->addCacheTags([
    'node:1',
  ]);
  $this
    ->assertResults($query, $vars, [
    'route' => [
      'node' => [
        'title' => 'Node A',
      ],
    ],
  ], $metadata);
  $node
    ->setTitle('Node B');
  $node
    ->save();
  $this
    ->assertResults($query, $vars, [
    'route' => [
      'node' => [
        'title' => 'Node B',
      ],
    ],
  ], $metadata);
}