Skip to content

Commit 452aa57

Browse files
committed
Fix failing test
1 parent c567892 commit 452aa57

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

src/lib/generators/ControllersGenerator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ public function generate():CodeFiles
9191
));
9292
}
9393

94+
// generate Module.php file for modules
9495
foreach ($action->modulesList as $moduleId => $moduleDetail) {
9596
// only generate Module.php file if they do not exist, do not override
9697
if (!file_exists(Yii::getAlias($moduleDetail['path'] . "/Module.php"))) {
97-
// $moduleNamespace = str_replace('\controllers', '', $action->prefixSettings['namespace']);
9898
$moduleFileGenerator = $this->makeModuleFile('Module', $moduleDetail['namespace'], $moduleId, $action);
9999
$this->files->add(new CodeFile(
100100
Yii::getAlias($moduleDetail['path'] . "/Module.php"),
@@ -195,7 +195,6 @@ public function makeModuleFile(string $class, string $namespace, $moduleId, $act
195195
$childModuleCode = <<<PHP
196196
\$this->modules = [
197197
'{$childModuleId}' => [
198-
// you should consider using a shorter namespace here!
199198
'class' => \\{$childModuleNamespace}\Module::class,
200199
],
201200
];

src/lib/generators/ModuleFileGenerator.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/unit/RestActionGeneratorTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function dataProvider():array
106106
'prefix' => '',
107107
'prefixSettings' => [],
108108
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'array'],
109+
'xRoute' => null,
109110
]),
110111
new RestAction([
111112
'id' => 'view',
@@ -118,6 +119,7 @@ public function dataProvider():array
118119
'modelName' => 'Post',
119120
'modelFqn' => 'app\models\Post',
120121
'responseWrapper' => ['item' => 'post', 'list' => null, 'type' => 'object'],
122+
'xRoute' => null,
121123
]),
122124
new RestAction([
123125
'id' => 'view-related-category',
@@ -132,6 +134,7 @@ public function dataProvider():array
132134
'modelName' => 'Post',
133135
'modelFqn' => 'app\models\Post',
134136
'responseWrapper' => ['item' => 'category', 'list' => null, 'type' => 'object'],
137+
'xRoute' => null,
135138
]),
136139
new RestAction([
137140
'id' => 'list-related-comments',
@@ -146,6 +149,7 @@ public function dataProvider():array
146149
'modelName' => 'Post',
147150
'modelFqn' => 'app\models\Post',
148151
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'array'],
152+
'xRoute' => null,
149153
]),
150154
new RestAction([
151155
'id' => 'list-for-post',
@@ -160,6 +164,7 @@ public function dataProvider():array
160164
'modelName' => 'Comment',
161165
'modelFqn' => 'app\models\Comment',
162166
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'array'],
167+
'xRoute' => null,
163168
]),
164169
new RestAction([
165170
'id' => 'create-for-post',
@@ -174,6 +179,7 @@ public function dataProvider():array
174179
'modelName' => 'Comment',
175180
'modelFqn' => 'app\models\Comment',
176181
'responseWrapper' => null,
182+
'xRoute' => null,
177183
]),
178184
new RestAction([
179185
'id' => 'view-for-category',
@@ -189,6 +195,7 @@ public function dataProvider():array
189195
'modelName' => 'Post',
190196
'modelFqn' => 'app\models\Post',
191197
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
198+
'xRoute' => null,
192199
]),
193200
new RestAction([
194201
'id' => 'view-for-post',
@@ -204,6 +211,7 @@ public function dataProvider():array
204211
'modelName' => 'Comment',
205212
'modelFqn' => 'app\models\Comment',
206213
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
214+
'xRoute' => null,
207215
]),
208216
new RestAction([
209217
'id' => 'delete-for-post',
@@ -219,6 +227,7 @@ public function dataProvider():array
219227
'modelName' => 'Comment',
220228
'modelFqn' => 'app\models\Comment',
221229
'responseWrapper' => null,
230+
'xRoute' => null,
222231
]),
223232
new RestAction([
224233
'id' => 'update-for-post',
@@ -234,6 +243,7 @@ public function dataProvider():array
234243
'modelName' => 'Comment',
235244
'modelFqn' => 'app\models\Comment',
236245
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
246+
'xRoute' => null,
237247
]),
238248
],
239249
],
@@ -252,6 +262,7 @@ public function dataProvider():array
252262
'modelName' => 'Pet',
253263
'modelFqn' => 'app\mymodels\Pet',
254264
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'array'],
265+
'xRoute' => null,
255266
]),
256267
new RestAction([
257268
'id' => 'create',
@@ -264,6 +275,7 @@ public function dataProvider():array
264275
'modelName' => 'Pet',
265276
'modelFqn' => 'app\mymodels\Pet',
266277
'responseWrapper' => null,
278+
'xRoute' => null,
267279
]),
268280
new RestAction([
269281
'id' => 'view',
@@ -276,6 +288,7 @@ public function dataProvider():array
276288
'modelName' => 'Pet',
277289
'modelFqn' => 'app\mymodels\Pet',
278290
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
291+
'xRoute' => null,
279292
]),
280293
new RestAction([
281294
'id' => 'delete',
@@ -288,6 +301,7 @@ public function dataProvider():array
288301
'modelName' => 'Pet',
289302
'modelFqn' => 'app\mymodels\Pet',
290303
'responseWrapper' => null,
304+
'xRoute' => null,
291305
]),
292306
new RestAction([
293307
'id' => 'update',
@@ -300,6 +314,7 @@ public function dataProvider():array
300314
'modelName' => 'Pet',
301315
'modelFqn' => 'app\mymodels\Pet',
302316
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
317+
'xRoute' => null,
303318
]),
304319
new RestAction([
305320
'id' => 'list',
@@ -312,6 +327,7 @@ public function dataProvider():array
312327
'modelName' => null,
313328
'modelFqn' => null,
314329
'responseWrapper' => null,
330+
'xRoute' => null,
315331
]),
316332
new RestAction([
317333
'id' => 'list',
@@ -324,6 +340,7 @@ public function dataProvider():array
324340
'modelName' => null,
325341
'modelFqn' => null,
326342
'responseWrapper' => null,
343+
'xRoute' => null,
327344
]),
328345
],
329346
],
@@ -362,6 +379,7 @@ public function dataProviderWithUrlPrefixes():array
362379
'namespace' => '\app\api\v1\controllers',
363380
],
364381
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'array'],
382+
'xRoute' => null
365383
]),
366384
new RestAction([
367385
'id' => 'create',
@@ -379,6 +397,7 @@ public function dataProviderWithUrlPrefixes():array
379397
'namespace' => '\app\api\v1\controllers',
380398
],
381399
'responseWrapper' => null,
400+
'xRoute' => null
382401
]),
383402
new RestAction([
384403
'id' => 'view',
@@ -393,6 +412,7 @@ public function dataProviderWithUrlPrefixes():array
393412
'prefix' => 'animals',
394413
'prefixSettings' => [],
395414
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
415+
'xRoute' => null
396416
]),
397417
new RestAction([
398418
'id' => 'delete',
@@ -407,6 +427,7 @@ public function dataProviderWithUrlPrefixes():array
407427
'prefix' => 'animals',
408428
'prefixSettings' => [],
409429
'responseWrapper' => null,
430+
'xRoute' => null
410431
]),
411432
new RestAction([
412433
'id' => 'update',
@@ -421,6 +442,7 @@ public function dataProviderWithUrlPrefixes():array
421442
'prefix' => 'animals',
422443
'prefixSettings' => [],
423444
'responseWrapper' => ['item' => '', 'list' => '', 'type' => 'object'],
445+
'xRoute' => null
424446
]),
425447
new RestAction([
426448
'id' => 'list',
@@ -433,6 +455,7 @@ public function dataProviderWithUrlPrefixes():array
433455
'modelName' => null,
434456
'modelFqn' => null,
435457
'responseWrapper' => null,
458+
'xRoute' => null
436459
]),
437460
new RestAction([
438461
'id' => 'list',
@@ -451,6 +474,7 @@ public function dataProviderWithUrlPrefixes():array
451474
'namespace' => '\app\modules\petinfo\controllers',
452475
],
453476
'responseWrapper' => null,
477+
'xRoute' => null
454478
]),
455479
],
456480
],

0 commit comments

Comments
 (0)