Completed
Pull Request — 8.x-3.x (#501)
by Philipp
04:28
created

RouteTest::testDeniedRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\Tests\graphql_core\Kernel\Routing;
4
5
use Drupal\Core\Path\AliasManagerInterface;
6
use Drupal\Tests\graphql_core\Kernel\GraphQLCoreTestBase;
7
8
/**
9
 * Test plugin based schema generation.
10
 *
11
 * @group graphql_core
12
 */
13
class RouteTest extends GraphQLCoreTestBase {
14
15
  public static $modules = [
16
    'graphql_context_test',
17
  ];
18
19
  /**
20
   * {@inheritdoc}
21
   */
22
  protected function setUp() {
23
    parent::setUp();
24
25
    $aliasManager = $this->prophesize(AliasManagerInterface::class);
26
    $aliasManager->getPathByAlias('/my/alias')->willReturn('/graphql/test/a');
27
    $aliasManager->getAliasByPath('/graphql/test/a')->willReturn('/my/other/alias');
28
    $aliasManager->getAliasByPath('/graphql/test/c')->willReturn('/graphql/test/c');
29
    $this->container->set('path.alias_manager', $aliasManager->reveal());
30
  }
31
32
  /**
33
   * Test if the schema is created properly.
34
   */
35
  public function testRoute() {
36
    // TODO: Check cache metadata.
37
    $metadata = $this->defaultCacheMetaData();
38
    $metadata->addCacheTags([
39
      '4xx-response',
40
    ]);
41
42
    $this->assertResults($this->getQueryFromFile('routing.gql'), [], [
43
      'route' => [
44
        'internal' => '/graphql/test/a',
45
        'aliased' => '/my/other/alias',
46
        'routed' => TRUE,
47
      ],
48
      'denied' => NULL,
49
    ], $metadata);
50
  }
51
52
}
53