@@ -61,6 +61,7 @@ public function test_it_generates_module_folders()
61
61
foreach (config ('modules.paths.generator ' ) as $ directory ) {
62
62
$ this ->assertDirectoryExists ($ this ->module_path ($ directory ['path ' ]));
63
63
}
64
+
64
65
$ this ->assertSame (0 , $ code );
65
66
}
66
67
@@ -72,6 +73,7 @@ public function test_it_generates_module_files()
72
73
$ path = $ this ->module_path ($ file );
73
74
$ this ->assertTrue ($ this ->finder ->exists ($ path ), "[ $ file] does not exists " );
74
75
}
76
+
75
77
$ path = $ this ->module_path ('module.json ' );
76
78
77
79
$ this ->assertTrue ($ this ->finder ->exists ($ path ), '[module.json] does not exists ' );
@@ -189,46 +191,48 @@ public function test_it_generates_module_namespace_using_studly_case()
189
191
{
190
192
$ code = $ this ->artisan ('module:make ' , ['name ' => ['ModuleName ' ]]);
191
193
192
- $ file = $ this ->finder ->get ($ this ->module_path ('app/Providers/ModuleNameServiceProvider.php ' , 'ModuleName ' ));
194
+ $ file = $ this ->finder ->get ($ this ->module_app_path ('app/Providers/ModuleNameServiceProvider.php ' , 'ModuleName ' ));
193
195
194
196
$ this ->assertMatchesSnapshot ($ file );
195
197
$ this ->assertSame (0 , $ code );
196
198
}
197
199
198
200
public function test_it_generates_a_plain_module_with_no_resources ()
199
201
{
200
- $ code = $ this ->artisan ('module:make ' , ['name ' => ['ModuleName ' ], '--plain ' => true ]);
202
+ $ code = $ this ->artisan ('module:make ' , ['name ' => ['Blog ' ], '--plain ' => true ]);
201
203
202
- $ path = $ this ->module_path ( ' Providers/ModuleNameServiceProvider .php ' , ' ModuleName ' );
204
+ $ path = $ this ->module_app_path ( ' app/ Providers/BlogServiceProvider .php ' );
203
205
$ this ->assertFalse ($ this ->finder ->exists ($ path ));
204
206
205
- $ path = $ this ->module_path ( ' Http/Controllers/ModuleNameController .php ' , ' ModuleName ' );
207
+ $ path = $ this ->module_app_path ( ' app/ Http/Controllers/BlogController .php ' );
206
208
$ this ->assertFalse ($ this ->finder ->exists ($ path ));
207
209
208
- $ path = $ this ->module_path ('Database/Seeders/ModuleNameDatabaseSeeder .php' , ' ModuleName ' );
210
+ $ path = $ this ->module_path ('database/seeders/BlogDatabaseSeeder .php ' );
209
211
$ this ->assertFalse ($ this ->finder ->exists ($ path ));
210
212
211
213
$ this ->assertSame (0 , $ code );
212
214
}
213
215
214
216
public function test_it_generates_a_plain_module_with_no_files ()
215
217
{
216
- $ code = $ this ->artisan ('module:make ' , ['name ' => ['ModuleName ' ], '--plain ' => true ]);
218
+ $ code = $ this ->artisan ('module:make ' , ['name ' => ['Blog ' ], '--plain ' => true ]);
217
219
218
220
foreach (config ('modules.stubs.files ' ) as $ file ) {
219
- $ path = $ this ->module_path ($ file, ' ModuleName ' );
221
+ $ path = $ this ->module_path ($ file );
220
222
$ this ->assertFalse ($ this ->finder ->exists ($ path ), "[ $ file] exists " );
221
223
}
222
- $ path = $ this ->module_path ('module.json ' , 'ModuleName ' );
224
+
225
+ $ path = $ this ->module_path ('module.json ' );
226
+
223
227
$ this ->assertTrue ($ this ->finder ->exists ($ path ), '[module.json] does not exists ' );
224
228
$ this ->assertSame (0 , $ code );
225
229
}
226
230
227
231
public function test_it_generates_plain_module_with_no_service_provider_in_modulejson_file ()
228
232
{
229
- $ code = $ this ->artisan ('module:make ' , ['name ' => ['ModuleName ' ], '--plain ' => true ]);
233
+ $ code = $ this ->artisan ('module:make ' , ['name ' => ['Blog ' ], '--plain ' => true ]);
230
234
231
- $ path = $ this ->module_path ('module.json ' , ' ModuleName ' );
235
+ $ path = $ this ->module_path ('module.json ' );
232
236
$ content = json_decode ($ this ->finder ->get ($ path ));
233
237
234
238
$ this ->assertCount (0 , $ content ->providers );
@@ -324,25 +328,28 @@ public function test_it_can_ignore_some_folders_to_generate_with_new_format()
324
328
325
329
public function test_it_can_ignore_resource_folders_to_generate ()
326
330
{
327
- $ this ->app ['config ' ]->set (
328
- 'modules.paths.generator.seeder ' ,
329
- ['path ' => 'Database/Seeders ' , 'generate ' => false ]
330
- );
331
- $ this ->app ['config ' ]->set ('modules.paths.generator.provider ' , ['path ' => 'Providers ' , 'generate ' => false ]);
332
- $ this ->app ['config ' ]->set (
333
- 'modules.paths.generator.route-provider ' ,
334
- ['path ' => 'Providers ' , 'generate ' => false ]
335
- );
336
- $ this ->app ['config ' ]->set (
337
- 'modules.paths.generator.controller ' ,
338
- ['path ' => 'Http/Controllers ' , 'generate ' => false ]
339
- );
331
+ $ this ->app ['config ' ]->set ('modules.paths.generator.seeder ' , [
332
+ 'path ' => 'database/seeders ' ,
333
+ 'generate ' => false ,
334
+ ]);
335
+ $ this ->app ['config ' ]->set ('modules.paths.generator.provider ' , [
336
+ 'path ' => 'app/Providers ' ,
337
+ 'generate ' => false ,
338
+ ]);
339
+ $ this ->app ['config ' ]->set ('modules.paths.generator.route-provider ' , [
340
+ 'path ' => 'app/Providers ' ,
341
+ 'generate ' => false ,
342
+ ]);
343
+ $ this ->app ['config ' ]->set ('modules.paths.generator.controller ' , [
344
+ 'path ' => 'app/Http/Controllers ' ,
345
+ 'generate ' => false ,
346
+ ]);
340
347
341
348
$ code = $ this ->artisan ('module:make ' , ['name ' => ['Blog ' ]]);
342
349
343
- $ this ->assertFileDoesNotExist ($ this ->module_path ('Database/Seeders ' ));
344
- $ this ->assertFileDoesNotExist ($ this ->module_path ( ' Providers ' ));
345
- $ this ->assertFileDoesNotExist ($ this ->module_path ( ' Http/Controllers ' ));
350
+ $ this ->assertFileDoesNotExist ($ this ->module_path ('database/seeders ' ));
351
+ $ this ->assertFileDoesNotExist ($ this ->module_app_path ( ' app/ Providers ' ));
352
+ $ this ->assertFileDoesNotExist ($ this ->module_app_path ( ' app/ Http/Controllers ' ));
346
353
$ this ->assertSame (0 , $ code );
347
354
}
348
355
@@ -362,17 +369,20 @@ public function test_it_generates_disabled_module_with_disabled_flag()
362
369
$ this ->assertSame (0 , $ code );
363
370
}
364
371
365
- public function test_it_generes_module_with_new_provider_location ()
372
+ public function test_it_generes_module_with_custom_provider_location ()
366
373
{
367
374
$ this ->app ['config ' ]->set ('modules.paths.generator.provider ' , ['path ' => 'Base/Providers ' , 'generate ' => true ]);
368
375
369
376
$ code = $ this ->artisan ('module:make ' , ['name ' => ['Blog ' ]]);
370
377
371
378
$ this ->assertDirectoryExists ($ this ->module_path ('Base/Providers ' ));
379
+
372
380
$ file = $ this ->finder ->get ($ this ->module_path ('module.json ' ));
373
381
$ this ->assertMatchesSnapshot ($ file );
382
+
374
383
$ file = $ this ->finder ->get ($ this ->module_path ('composer.json ' ));
375
384
$ this ->assertMatchesSnapshot ($ file );
385
+
376
386
$ this ->assertSame (0 , $ code );
377
387
}
378
388
0 commit comments