Completed
Pull Request — 8.x-3.x (#456)
by Philipp
03:01
created

RouteEntityTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 18
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 18
loc 18
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace Drupal\Tests\graphql_core\Kernel\Routing;
4
5
use Drupal\Core\Entity\Entity\EntityViewMode;
6
use Drupal\field\Entity\FieldConfig;
7
use Drupal\field\Entity\FieldStorageConfig;
8
use Drupal\image\Entity\ImageStyle;
9
use Drupal\simpletest\ContentTypeCreationTrait;
10
use Drupal\simpletest\NodeCreationTrait;
11
use Drupal\Tests\graphql\Kernel\GraphQLFileTestBase;
12
use Drupal\Tests\graphql\Traits\EnableCliCacheTrait;
13
use Drupal\user\Entity\Role;
14
15
/**
16
 * Test file attachments.
17
 *
18
 * @group graphql_image
19
 */
20
class RouteEntityTest extends GraphQLFileTestBase {
21
  use NodeCreationTrait;
22
  use ContentTypeCreationTrait;
23
  use EnableCliCacheTrait;
24
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public static $modules = [
29
    'node',
30
    'field',
31
    'text',
32
    'filter',
33
    'graphql_core',
34
  ];
35
36
  /**
37
   * {@inheritdoc}
38
   */
39 View Code Duplication
  protected function setUp() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    parent::setUp();
41
    $this->installConfig('node');
42
    $this->installConfig('filter');
43
    $this->installEntitySchema('node');
44
    $this->installSchema('node', 'node_access');
45
    $this->createContentType(['type' => 'test']);
46
47
    Role::load('anonymous')
48
      ->grantPermission('access content')
49
      ->save();
50
51
    EntityViewMode::create([
52
      'targetEntityType' => 'node',
53
      'id' => "node.graphql",
54
    ])->save();
55
56
  }
57
58
  public function testRouteEntity() {
59
    $node = $this->createNode([
60
      'title' => 'Node A',
61
      'type' => 'test',
62
    ]);
63
64
    $node->save();
65
66
    $result = $this->requestWithQueryFile('route_entity.gql', ['path' => '/node/' . $node->id()]);
67
    $entity = $result['data']['route']['node'];
68
69
    $this->assertEquals('Node A', $entity['title']);
70
71
    $node->setTitle('Node B');
72
    $node->save();
73
74
    $result = $this->requestWithQueryFile('route_entity.gql', ['path' => '/node/' . $node->id()]);
75
    $entity = $result['data']['route']['node'];
76
77
    $this->assertEquals('Node B', $entity['title']);
78
  }
79
80
}
81