Skip to content

Commit c20eba1

Browse files
committed
Bugfix
Add more tests
1 parent 86eb7e7 commit c20eba1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Console/Commands/ControllerMakeCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ protected function buildModelReplacements(array $replace)
186186
$modelSlug = Str::slug(Str::plural($label, 2));
187187
$viewDir = $modelSlug;
188188
$routeBase = $modelSlug;
189-
if ($this->option('views-dir')) {
190-
$viewDir = $this->option('views-dir');
191-
$viewDir = str_replace('/', '.', $viewDir);
189+
190+
$dir = $this->option('views-dir');
191+
if ($dir) {
192+
$dir = str_replace('/', '.', $dir);
193+
$viewDir = $dir . '.' . $modelSlug;
192194
}
193195

194196
if ($this->option('route-base')) {

tests/Feature/CrayCommandTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ public function test_it_generates_view_paths_correctly_when_subdirectory_is_spec
153153
{
154154
$this->artisan('cray Models/Post --controller-dir=dashboard --views-dir=dashboard/system');
155155
$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');
156+
$postController = file_get_contents(app_path('Http/Controllers/Dashboard/PostController.php'));
157+
158+
$this->assertStringContainsString("@include('dashboard.system.posts._form')", $createBladeView,'Include path is incorrect');
159+
160+
$this->assertStringContainsString("return view('dashboard.system.posts.index'", $postController,'View path is incorrect');
157161
}
158162
}

0 commit comments

Comments
 (0)