Completed
Push — 8.x-3.x ( 8b362e...1b1eb9 )
by Philipp
02:48
created

BundleLessEntityTest::testConfiguredField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace Drupal\Tests\graphql_core\Kernel\Entity;
4
5
use Drupal\field\Entity\FieldConfig;
6
use Drupal\field\Entity\FieldStorageConfig;
7
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
8
9
/**
10
 * Tests for bundle-less entities.
11
 *
12
 * Test edge cases of entities without bundles (e.g. the user entity).
13
 */
14
class BundleLessEntityTest extends GraphQLContentTestBase {
15
16
  /**
17
   * {@inheritdoc}
18
   */
19
  protected function setUp() {
20
    parent::setUp();
21
    FieldStorageConfig::create([
22
      'field_name' => 'field_test',
23
      'entity_type' => 'user',
24
      'type' => 'boolean',
25
      'cardinality' => 1,
26
    ])->save();
27
28
    FieldConfig::create([
29
      'entity_type' => 'user',
30
      'bundle' => 'user',
31
      'field_name' => 'field_test',
32
      'label' => 'Test',
33
    ])->save();
34
  }
35
36
  /**
37
   * Test if a field is available on the user type.
38
   *
39
   * Regression test for: https://github.com/drupal-graphql/graphql/issues/560
40
   */
41
  public function testConfiguredField() {
42
    $this->assertGraphQLFields([
43
      ['User', 'fieldTest', 'Boolean'],
44
    ]);
45
  }
46
47
}
48