@@ -40,7 +40,7 @@ public function test_it_scaffolds_crud_artifacts()
4040 $ this ->assertFileExists (app_path ('Http/Requests/PostUpdateRequest.php ' ));
4141 $ this ->assertFileExists (app_path ('Http/Requests/PostStoreRequest.php ' ));
4242 $ this ->assertFileExists (base_path ('database/factories/PostFactory.php ' ));
43- $ this ->assertFileExists (resource_path ('views/posts ' ));
43+ $ this ->assertDirectoryDoesNotExist (resource_path ('views/posts ' ));
4444 $ this ->assertFileExists (resource_path ("views/posts/index.blade.php " ));
4545 $ this ->assertFileExists (resource_path ("views/posts/create.blade.php " ));
4646 $ this ->assertFileExists (resource_path ("views/posts/_form.blade.php " ));
@@ -73,7 +73,7 @@ public function test_it_scaffolds_crud_artifacts_model_in_models_dir_with_namesp
7373 $ this ->assertFileDoesNotExist (app_path ('Http/Requests/PostUpdateRequest.php ' ));
7474 $ this ->assertFileDoesNotExist (app_path ('Http/Requests/PostStoreRequest.php ' ));
7575 $ this ->assertFileDoesNotExist (base_path ('database/factories/PostFactory.php ' ));
76- $ this ->assertFileDoesNotExist (resource_path ('views/posts ' ));
76+ $ this ->assertDirectoryDoesNotExist (resource_path ('views/posts ' ));
7777
7878 $ this ->artisan ('cray Models/Post ' );
7979
@@ -82,7 +82,7 @@ public function test_it_scaffolds_crud_artifacts_model_in_models_dir_with_namesp
8282 $ this ->assertFileExists (app_path ('Http/Requests/PostUpdateRequest.php ' ));
8383 $ this ->assertFileExists (app_path ('Http/Requests/PostStoreRequest.php ' ));
8484 $ this ->assertFileExists (base_path ('database/factories/PostFactory.php ' ));
85- $ this ->assertFileExists (resource_path ('views/posts ' ));
85+ $ this ->assertDirectoryExists (resource_path ('views/posts ' ));
8686 $ this ->assertFileExists (resource_path ("views/posts/index.blade.php " ));
8787 $ this ->assertFileExists (resource_path ("views/posts/create.blade.php " ));
8888 $ this ->assertFileExists (resource_path ("views/posts/_form.blade.php " ));
@@ -106,4 +106,53 @@ public function test_it_scaffolds_crud_artifacts_model_in_models_dir_with_namesp
106106Request created successfully in /app/Http/Requests/PostUpdateRequest.php " . PHP_EOL ;
107107 $ this ->assertSame ($ expectedOutput , $ actualOutput );
108108 }
109+
110+ public function test_it_generates_views_and_the_controller_under_the_given_directory_when_controller_directory_is_specified ()
111+ {
112+ //Make sure no artifact related to Post exists
113+ $ this ->assertFileDoesNotExist (app_path ('Models/Post.php ' ));
114+ $ this ->assertFileDoesNotExist (app_path ('Http/Controllers/Dashboard/PostController.php ' ));
115+ $ this ->assertFileDoesNotExist (app_path ('Http/Requests/PostUpdateRequest.php ' ));
116+ $ this ->assertFileDoesNotExist (app_path ('Http/Requests/PostStoreRequest.php ' ));
117+ $ this ->assertFileDoesNotExist (base_path ('database/factories/PostFactory.php ' ));
118+ $ this ->assertDirectoryDoesNotExist (resource_path ('views/dashboard/posts ' ));
119+
120+ $ this ->artisan ('cray Models/Post --controller-dir=dashboard --views-dir=dashboard ' );
121+
122+ $ this ->assertFileExists (app_path ('Models/Post.php ' ));
123+ $ this ->assertFileExists (app_path ('Http/Controllers/Dashboard/PostController.php ' ));
124+ $ this ->assertFileExists (app_path ('Http/Requests/PostUpdateRequest.php ' ));
125+ $ this ->assertFileExists (app_path ('Http/Requests/PostStoreRequest.php ' ));
126+ $ this ->assertFileExists (base_path ('database/factories/PostFactory.php ' ));
127+ $ this ->assertDirectoryExists (resource_path ('views/dashboard/posts ' ));
128+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/index.blade.php " ));
129+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/create.blade.php " ));
130+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/_form.blade.php " ));
131+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/edit.blade.php " ));
132+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/show.blade.php " ));
133+ $ this ->assertFileExists (resource_path ("views/dashboard/posts/modals/delete.blade.php " ));
134+
135+ $ actualOutput = Artisan::output ();
136+
137+ $ expectedOutput = "Factory created successfully in /database/factories/PostFactory.php
138+ Created Migration: 2020_03_14_153546_create_posts_table
139+ Model created successfully in /app/Models/Post.php
140+ Controller created successfully in /app/Http/Controllers/Dashboard/PostController.php
141+ View created successfully in /resources/views/dashboard/posts/index.blade.php
142+ View created successfully in /resources/views/dashboard/posts/create.blade.php
143+ View created successfully in /resources/views/dashboard/posts/_form.blade.php
144+ View created successfully in /resources/views/dashboard/posts/edit.blade.php
145+ View created successfully in /resources/views/dashboard/posts/show.blade.php
146+ View created successfully in /resources/views/dashboard/posts/modals/delete.blade.php
147+ Request created successfully in /app/Http/Requests/PostStoreRequest.php
148+ Request created successfully in /app/Http/Requests/PostUpdateRequest.php " . PHP_EOL ;
149+ $ this ->assertSame ($ expectedOutput , $ actualOutput );
150+ }
151+
152+ public function test_it_generates_view_paths_correctly_when_subdirectory_is_specified_for_the_controller ()
153+ {
154+ $ this ->artisan ('cray Models/Post --controller-dir=dashboard --views-dir=dashboard/system ' );
155+ $ createBladeView = file_get_contents (resource_path ('views/dashboard/system/posts/create.blade.php ' ));
156+ $ this ->assertStringContainsString ("@include('dashboard.system.posts._form') " , $ createBladeView ,'Include path is correct ' );
157+ }
109158}
0 commit comments