-
Notifications
You must be signed in to change notification settings - Fork 52
/
ControllerTest.php
86 lines (62 loc) · 1.92 KB
/
ControllerTest.php
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
<?php
namespace DrupalCodeGenerator\Tests\Generator;
use DrupalCodeGenerator\Command\Controller;
use DrupalCodeGenerator\Test\GeneratorTest;
/**
* Test for controller command.
*/
final class ControllerTest extends GeneratorTest {
protected $fixtureDir = __DIR__;
/**
* Test callback.
*/
public function testGenerator(): void {
$input = [
'Foo',
'foo',
'FooController',
'Yes',
'database',
'',
'Yes',
'example.bar',
'/foo/example',
'Bar',
'access content',
];
$this->execute(new Controller(), $input);
$expected_display = <<< 'TXT'
Welcome to controller generator!
––––––––––––––––––––––––––––––––––
Module name [%default_name%]:
➤
Module machine name [foo]:
➤
Class [FooController]:
➤
Would you like to inject dependencies? [No]:
➤
Type the service name or use arrows up/down. Press enter to continue:
➤
Type the service name or use arrows up/down. Press enter to continue:
➤
Would you like to create a route for this controller? [Yes]:
➤
Route name [foo.example]:
➤
Route path [/foo/example]:
➤
Route title [Example]:
➤
Route permission [access content]:
➤
The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• foo.routing.yml
• src/Controller/FooController.php
TXT;
$this->assertDisplay($expected_display);
$this->assertGeneratedFile('src/Controller/FooController.php', '_controller.php');
$this->assertGeneratedFile('foo.routing.yml', '_controller_routing.yml');
}
}