Skip to content

Commit

Permalink
Ensure all generated directories exist
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary committed Feb 13, 2020
1 parent c6e5158 commit d1bdf11
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Generators/Statements/EventGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function output(array $tree): array
}

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path));
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Statements/FormRequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function output(array $tree): array
}

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path));
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Statements/JobGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function output(array $tree): array
}

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path));
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Statements/MailGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function output(array $tree): array
}

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path));
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/Statements/ViewGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function output(array $tree): array
}

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path));
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
Expand Down
5 changes: 5 additions & 0 deletions src/Generators/TestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public function output(array $tree): array
/** @var \Blueprint\Models\Controller $controller */
foreach ($tree['controllers'] as $controller) {
$path = $this->getPath($controller);

if (!$this->files->exists(dirname($path))) {
$this->files->makeDirectory(dirname($path), 0755, true);
}

$this->files->put(
$path,
$this->populateStub($stub, $controller)
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Generator/Statements/EventGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function output_writes_events()
->with('app/Events/UserCreated.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('app/Events');
->with('app/Events', 0755, true);
$this->files->expects('put')
->with('app/Events/UserCreated.php', $this->fixture('events/user-created.php'));

Expand Down Expand Up @@ -137,7 +137,7 @@ public function it_respects_configuration()
->with('src/path/Events')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('src/path/Events');
->with('src/path/Events', 0755, true);
$this->files->expects('exists')
->with('src/path/Events/NewPost.php')
->andReturnFalse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function output_writes_form_requests()
->with('app/Http/Requests/PostIndexRequest.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('app/Http/Requests');
->with('app/Http/Requests', 0755, true);
$this->files->expects('put')
->with('app/Http/Requests/PostIndexRequest.php', $this->fixture('form-requests/post-index.php'));

Expand Down Expand Up @@ -143,7 +143,7 @@ public function output_supports_nested_form_requests()
->with('app/Http/Requests/Admin/UserStoreRequest.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('app/Http/Requests/Admin');
->with('app/Http/Requests/Admin', 0755, true);
$this->files->expects('put')
->with('app/Http/Requests/Admin/UserStoreRequest.php', $this->fixture('form-requests/nested-components.php'));

Expand Down Expand Up @@ -172,7 +172,7 @@ public function it_respects_configuration()
->with('src/path/Http/Requests/PostStoreRequest.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('src/path/Http/Requests');
->with('src/path/Http/Requests', 0755, true);
$this->files->expects('put')
->with('src/path/Http/Requests/PostStoreRequest.php', $this->fixture('form-requests/form-request-configured.php'));

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Generator/Statements/JobGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function output_writes_jobs()
->with('app/Jobs/CreateUser.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('app/Jobs');
->with('app/Jobs', 0755, true);
$this->files->expects('put')
->with('app/Jobs/CreateUser.php', $this->fixture('jobs/create-user.php'));

Expand Down Expand Up @@ -140,7 +140,7 @@ public function it_respects_configuration()
->with('src/path/Jobs/SyncMedia.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('src/path/Jobs');
->with('src/path/Jobs', 0755, true);
$this->files->expects('put')
->with('src/path/Jobs/SyncMedia.php', $this->fixture('jobs/job-configured.php'));

Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Generator/Statements/MailGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function output_writes_mails()
->with('app/Mail/ReviewPost.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('app/Mail');
->with('app/Mail', 0755, true);
$this->files->expects('put')
->with('app/Mail/ReviewPost.php', $this->fixture('mailables/review-post.php'));

Expand Down Expand Up @@ -140,7 +140,7 @@ public function it_respects_configuration()
->with('src/path/Mail/ReviewNotification.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('src/path/Mail');
->with('src/path/Mail', 0755, true);
$this->files->expects('put')
->with('src/path/Mail/ReviewNotification.php', $this->fixture('mailables/mail-configured.php'));

Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/Generator/Statements/ViewGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public function output_writes_views_for_render_statements()
->with('resources/views/post/show.blade.php')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('resources/views/post')
->andReturnFalse();
->with('resources/views/post', 0755, true);
$this->files->expects('put')
->with('resources/views/post/show.blade.php', str_replace('DummyView', 'post.show', $template));

Expand Down
6 changes: 5 additions & 1 deletion tests/Feature/Generator/TestGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ public function output_writes_migration_for_controller_tree($definition, $path,
$this->files->expects('get')
->with('stubs/test/case.stub')
->andReturn(file_get_contents('stubs/test/case.stub'));

$this->files->expects('exists')
->with('tests/Feature/Http/Controllers')
->andReturnFalse();
$this->files->expects('makeDirectory')
->with('tests/Feature/Http/Controllers', 0755, true);
$this->files->expects('put')
->with($path, $this->fixture($test));

Expand Down

0 comments on commit d1bdf11

Please sign in to comment.