-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessageTest.php
More file actions
175 lines (134 loc) · 5.56 KB
/
Copy pathMessageTest.php
File metadata and controls
175 lines (134 loc) · 5.56 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
declare(strict_types=1);
namespace DotTest\Maker;
use Dot\Maker\Message;
use PHPUnit\Framework\TestCase;
use const PHP_EOL;
class MessageTest extends TestCase
{
public function testWillInstantiate(): void
{
$message = new Message('test');
$this->assertContainsOnlyInstancesOf(Message::class, [$message]);
}
public function testCanUsePriorityAccessors(): void
{
$message = new Message('test');
$this->assertSame(0, $message->getPriority());
$message->setPriority(1);
$this->assertSame(1, $message->getPriority());
$message = new Message('test', 1);
$this->assertSame(1, $message->getPriority());
}
public function testWillAppend(): void
{
$message = new Message('test');
$this->assertSame('test', (string) $message);
$message->append('-message');
$this->assertSame('test-message', (string) $message);
$message->appendLine('new line');
$this->assertSame('test-message' . PHP_EOL . 'new line', (string) $message);
}
public function testWillParseAddCommandToConfigMessage(): void
{
$message = Message::addCommandToConfig('App\\Module\\Command\\TestCommand');
$expected = <<<EXP
add to \033[97mconfig/autoload/cli.global.php\033[0m under \033[97mdot_cli\033[0m.\033[97mcommands\033[0m:
\033[93m App\\Module\\Command\\TestCommand::getDefaultName() => App\\Module\\Command\\TestCommand::class,\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_COMMAND_TO_CONFIG, $message->getPriority());
}
public function testWillParseAddConfigProviderToConfigMessage(): void
{
$message = Message::addConfigProviderToConfig('App\\Module\\ConfigProvider');
$expected = <<<EXP
add to \033[97mconfig/config.php\033[0m:
\033[93m App\\Module\\ConfigProvider::class,\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_CONFIG_PROVIDER_TO_CONFIG, $message->getPriority());
}
public function testWillParseAddCoreConfigProviderToConfigMessage(): void
{
$message = Message::addCoreConfigProviderToConfig('Core\\Module\\ConfigProvider');
$expected = <<<EXP
add to \033[97mconfig/config.php\033[0m:
\033[93m Core\\Module\\ConfigProvider::class,\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_CORE_CONFIG_PROVIDER_TO_CONFIG, $message->getPriority());
}
public function testWillParseAddModuleToComposerMessage(): void
{
$message = Message::addModuleToComposer('Api', 'Module');
$expected = <<<EXP
add to \033[97mcomposer.json\033[0m under \033[97mautoload\033[0m.\033[97mpsr-4\033[0m:
\033[93m "Api\\\\Module\\\\": "src/Module/src/"\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_MODULE_TO_COMPOSER, $message->getPriority());
}
public function testWillParseAddCoreModuleToComposerMessage(): void
{
$message = Message::addCoreModuleToComposer('Module');
$expected = <<<EXP
add to \033[97mcomposer.json\033[0m under \033[97mautoload\033[0m.\033[97mpsr-4\033[0m:
\033[93m "Core\\\\Module\\\\": "src/Core/src/Module/src/"\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_CORE_MODULE_TO_COMPOSER, $message->getPriority());
}
public function testWillParseAddMiddlewareToPipelineMessage(): void
{
$message = Message::addMiddlewareToPipeline('App\\Module\\Middleware\\TestMiddleware');
$expected = <<<EXP
add to \033[97mconfig/pipeline.php\033[0m:
\033[93m \$app->pipe(App\\Module\\Middleware\\TestMiddleware::class);\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_MIDDLEWARE_TO_PIPELINE, $message->getPriority());
}
public function testWillParseAddRoutesToAuthConfigMessage(): void
{
$message = Message::addRoutesToAuthConfig(
'config/autoload/authorization.php',
'App\\Module\\RoutesDelegator.php'
);
$expected = <<<EXP
add to \033[97mconfig/autoload/authorization.php\033[0m
the routes registered in \033[97mApp\\Module\\RoutesDelegator.php\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::ADD_ROUTES_TO_AUTH_CONFIG, $message->getPriority());
}
public function testWillParseCheckFilesMessage(): void
{
$message = Message::checkFiles();
$expected = <<<EXP
\033[91mReview each new file, verify their contents and start adding logic to them.\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::CHECK_FILES, $message->getPriority());
}
public function testWillParseDumpComposerAutoloaderMessage(): void
{
$message = Message::dumpComposerAutoloader();
$expected = <<<EXP
dump Composer autoloader by executing this command:
\033[93m composer dump\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::DUMP_COMPOSER_AUTOLOADER, $message->getPriority());
}
public function testWillParseGenerateMigrationMessage(): void
{
$message = Message::generateMigration();
$expected = <<<EXP
generate Doctrine migration:
\033[93m php ./vendor/bin/doctrine-migrations diff\033[0m
EXP;
$this->assertSame($expected, (string) $message);
$this->assertSame(Message::GENERATE_MIGRATION, $message->getPriority());
}
}