forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleGeneratorTest.php
More file actions
109 lines (98 loc) · 2.97 KB
/
Copy pathModuleGeneratorTest.php
File metadata and controls
109 lines (98 loc) · 2.97 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
<?php
/**
* @file
* Contains Drupal\AppConsole\Test\Generator\ModuleGeneratorTest.
*/
namespace Drupal\AppConsole\Test\Generator;
use Drupal\AppConsole\Generator\ModuleGenerator;
class ModuleGeneratorTest extends GeneratorTest
{
/**
* Module generator test
*
* @dataProvider commandData
*/
public function testGenerateModule($parameters)
{
list(
$module,
$machine_name,
$dir,
$description,
$core,
$package,
$controller,
$composer,
$dependencies,
$tests
) = $parameters;
$this->getGenerator()->generate(
$module,
$machine_name,
$dir,
$description,
$core,
$package,
$controller,
$composer,
$dependencies,
$tests
);
$files = [
$machine_name . '.info.yml',
$machine_name . '.module',
];
foreach ($files as $file) {
$this->assertTrue(
file_exists($dir . '/' . $machine_name . '/' . $file),
sprintf('%s has been generated', $dir . '/' . $machine_name . '/' . $file)
);
}
if ($controller) {
$this->assertTrue(
file_exists($dir . '/' . $machine_name . '/src/Controller/DefaultController.php'),
sprintf('%s has been generated',
$dir . $machine_name . '/src/Controller/DefaultController.php'
)
);
$this->assertTrue(
file_exists($dir . '/' . $machine_name . "/$machine_name.routing.yml"),
sprintf('%s has been generated',
$dir . '/' . $machine_name . "/$machine_name.routing.yml"
)
);
if ($tests) {
$this->assertTrue(
file_exists($dir . '/' . $machine_name . '/Tests/Controller/DefaultControllerTest.php'),
sprintf('%s has been generated',
$dir . '/' . $machine_name . '/Tests/Controller/DefaultControllerTest.php'
)
);
}
}
}
public function commandData()
{
$this->setUpTemporalDirectory();
return [
[
['Foo', 'foo' . rand(), $this->dir, 'Description', '8.x', 'Other', false, false, null, false],
],
[
['Foo', 'foo' . rand(), $this->dir, 'Description', '8.x', 'Other', false, false, null, true],
],
[
['Foo', 'foo' . rand(), $this->dir, 'Description', '8.x', 'Other', false, false, null, false],
],
[
['Foo', 'foo' . rand(), $this->dir, 'Description', '8.x', 'Other', true, true, null, true],
],
];
}
protected function getGenerator()
{
$generator = new ModuleGenerator();
$generator->setSkeletonDirs(__DIR__ . '/../../templates');
return $generator;
}
}