You are here

public function AccessUnpublishedRouteLoadTest::testUnpublishedRouteLoad in Access unpublished 8

@covers \Drupal\access_unpublished\Plugin\GraphQL\DataProducer\AccessUnpublishedRouteLoad::resolveUnpublished

File

tests/src/Kernel/graphql/DataProducer/AccessUnpublishedRouteLoadTest.php, line 34

Class

AccessUnpublishedRouteLoadTest
Data producers AccessUnpublishedRouteLoad test class.

Namespace

Drupal\Tests\access_unpublished\Kernel\graphql\DataProducer

Code

public function testUnpublishedRouteLoad() : void {
  $node = Node::create([
    'title' => 'Unpublished',
    'type' => 'test',
    'status' => FALSE,
  ]);
  $node
    ->save();
  $access_token = AccessToken::create([
    'entity_type' => 'node',
    'entity_id' => $node
      ->id(),
    'expire' => -1,
  ]);
  $access_token
    ->save();
  $result = $this
    ->executeDataProducer('access_unpublished_route_load', [
    'path' => $node
      ->toUrl()
      ->toString(),
    'token' => $access_token->value->value,
  ]);
  $this
    ->assertNotNull($result);
  $this
    ->assertEquals('entity.node.canonical', $result
    ->getRouteName());
  $this
    ->markTestIncomplete('Incomplete until https://www.drupal.org/project/drupal/issues/3180960 is fixed.');
  $result = $this
    ->executeDataProducer('access_unpublished_route_load', [
    'path' => $node
      ->toUrl()
      ->toString(),
  ]);
  $this
    ->assertEmpty($result);
}