-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathViewsTestBase.php
More file actions
88 lines (75 loc) · 1.9 KB
/
ViewsTestBase.php
File metadata and controls
88 lines (75 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Drupal\Tests\graphql_views\Kernel;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
use Drupal\Tests\graphql_core\Kernel\GraphQLContentTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
use Drupal\Tests\node\Traits\NodeCreationTrait;
/**
* Base class for test views support in GraphQL.
*
* @group graphql_views
*/
abstract class ViewsTestBase extends GraphQLContentTestBase {
use NodeCreationTrait;
use ContentTypeCreationTrait;
use EntityReferenceTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field',
'filter',
'text',
'views',
'taxonomy',
'graphql_core',
'graphql_views',
'graphql_views_test',
];
/**
* A List of letters.
*
* @var string[]
*/
protected $letters = ['A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->installEntitySchema('view');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(['node', 'filter', 'views', 'graphql_views_test']);
$this->createEntityReferenceField('node', 'test', 'field_tags', 'Tags', 'taxonomy_term');
Vocabulary::create([
'name' => 'Tags',
'vid' => 'tags',
])->save();
$terms = [];
$terms['A'] = Term::create([
'name' => 'Term A',
'vid' => 'tags',
]);
$terms['A']->save();
$terms['B'] = Term::create([
'name' => 'Term B',
'vid' => 'tags',
]);
$terms['B']->save();
$terms['C'] = Term::create([
'name' => 'Term C',
'vid' => 'tags',
]);
$terms['C']->save();
foreach ($this->letters as $index => $letter) {
$this->createNode([
'title' => 'Node ' . $letter,
'type' => 'test',
'field_tags' => $terms[$letter],
])->save();
}
}
}