forked from Chi-teck/drupal-code-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityBundleClassTest.php
More file actions
150 lines (118 loc) · 3.54 KB
/
EntityBundleClassTest.php
File metadata and controls
150 lines (118 loc) · 3.54 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
declare(strict_types=1);
namespace DrupalCodeGenerator\Tests\Functional\Generator\Entity;
use DrupalCodeGenerator\Command\Entity\EntityBundleClass;
use DrupalCodeGenerator\Test\Functional\GeneratorTestBase;
/**
* Tests entity:bundle-class generator.
*/
final class EntityBundleClassTest extends GeneratorTestBase {
protected string $fixtureDir = __DIR__ . '/_entity_bundle_class';
/**
* Test callback.
*/
public function testSingleBundleWithoutBaseClass(): void {
$input = [
'foo',
'Foo',
'Content',
'Article',
'ArticleBundle',
'No',
];
$this->execute(EntityBundleClass::class, $input);
$expected_display = <<< 'TXT'
Welcome to bundle-class generator!
––––––––––––––––––––––––––––––––––––
Module machine name:
➤
Module name [Foo]:
➤
Entity type:
[1] Content block
[2] Comment
[3] File
[4] Custom menu link
[5] Content
[6] URL alias
[7] Taxonomy term
[8] User
➤
Bundles, comma separated:
[1] Article
[2] Basic page
➤
Class for "Article" bundle [Article]:
➤
Use a base class? [No]:
➤
The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• foo.info.yml
• foo.module
• src/Entity/Node/ArticleBundle.php
TXT;
$this->assertDisplay($expected_display);
$this->fixtureDir .= '/_n_base_class';
$this->assertGeneratedFile('foo.module');
$this->assertGeneratedFile('src/Entity/Node/ArticleBundle.php');
}
/**
* Test callback.
*/
public function testAllBundlesWithBaseClass(): void {
$input = [
'foo',
'Foo',
'Content',
'1, 2',
'Article',
'Page',
'Yes',
];
$this->execute(EntityBundleClass::class, $input);
$expected_display = <<< 'TXT'
Welcome to bundle-class generator!
––––––––––––––––––––––––––––––––––––
Module machine name:
➤
Module name [Foo]:
➤
Entity type:
[1] Content block
[2] Comment
[3] File
[4] Custom menu link
[5] Content
[6] URL alias
[7] Taxonomy term
[8] User
➤
Bundles, comma separated:
[1] Article
[2] Basic page
➤
Class for "Article" bundle [Article]:
➤
Class for "Basic page" bundle [Page]:
➤
Use a base class? [No]:
➤
Base class [NodeBase]:
➤
The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• foo.info.yml
• foo.module
• src/Entity/Node/Article.php
• src/Entity/Node/NodeBase.php
• src/Entity/Node/Page.php
TXT;
$this->assertDisplay($expected_display);
$this->fixtureDir .= '/_w_base_class';
$this->assertGeneratedFile('foo.module');
$this->assertGeneratedFile('src/Entity/Node/NodeBase.php');
$this->assertGeneratedFile('src/Entity/Node/Article.php');
$this->assertGeneratedFile('src/Entity/Node/Page.php');
}
}