-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from pemudakoding/main
fix: DTO generated at the wrong place should be present in application layer
- Loading branch information
Showing
19 changed files
with
91 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 5 additions & 6 deletions
11
.../Domain/DataTransferObjectMakeCommand.php → ...ication/DataTransferObjectMakeCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
tests/Feature/Commands/Application/DataTransferObjectMakeCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Commands; | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\File; | ||
use Illuminate\Support\Str; | ||
use KoalaFacade\DiamondConsole\Exceptions\FileAlreadyExistException; | ||
|
||
it(description: 'can generate new DTO') | ||
->tap(function () { | ||
$filePath = base_path(path: applicationPath() . '/DataTransferObjects/Post/PostData.php'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeFalse(); | ||
|
||
Artisan::call(command: 'diamond:install'); | ||
Artisan::call(command: 'application:make:data-transfer-object PostData Post'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeTrue() | ||
->and( | ||
value: Str::contains( | ||
haystack: File::get(path: $filePath), | ||
needles: ['{{ class }}', '{{ namespace }}'] | ||
) | ||
)->toBeFalse(); | ||
}) | ||
->group(groups: 'commands'); | ||
|
||
it(description: 'can generate new DTO with separator') | ||
->tap(function () { | ||
$filePath = base_path(path: applicationPath() . '/DataTransferObjects/Post/Foo/BarData.php'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeFalse(); | ||
|
||
Artisan::call(command: 'diamond:install'); | ||
Artisan::call(command: 'application:make:data-transfer-object Foo/BarData Post'); | ||
|
||
expect(value: File::exists(path: $filePath)) | ||
->toBeTrue() | ||
->and( | ||
value: Str::contains( | ||
haystack: File::get(path: $filePath), | ||
needles: ['{{ class }}', '{{ namespace }}'] | ||
) | ||
) | ||
->toBeFalse(); | ||
}) | ||
->group(groups: 'commands'); | ||
|
||
it(description: 'can force generate exists DTO') | ||
->tap(function () { | ||
$filePath = base_path(path: applicationPath() . '/DataTransferObjects/Post/PostData.php'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeFalse(); | ||
|
||
Artisan::call(command: 'diamond:install'); | ||
Artisan::call(command: 'application:make:data-transfer-object PostData Post'); | ||
Artisan::call(command: 'application:make:data-transfer-object PostData Post --force'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeTrue() | ||
->and( | ||
value: Str::contains( | ||
haystack: File::get(path: $filePath), | ||
needles: ['{{ class }}', '{{ namespace }}'] | ||
) | ||
)->toBeFalse(); | ||
}) | ||
->group(groups: 'commands'); | ||
|
||
it(description: 'cannot generate the DTO, if the DTO already exists') | ||
->tap(function () { | ||
$filePath = base_path(path: applicationPath() . '/DataTransferObjects/Post/PostData.php'); | ||
|
||
expect(value: File::exists(path: $filePath))->toBeFalse(); | ||
|
||
Artisan::call(command: 'diamond:install'); | ||
Artisan::call(command: 'application:make:data-transfer-object PostData Post'); | ||
|
||
expect(value:File::exists(path: $filePath))->toBeTrue(); | ||
|
||
Artisan::call(command: 'application:make:data-transfer-object PostData Post'); | ||
}) | ||
->group(groups: 'commands') | ||
->throws(exception: FileAlreadyExistException::class); |
File renamed without changes.
File renamed without changes.
85 changes: 0 additions & 85 deletions
85
tests/Feature/Commands/DataTransferObjectMakeCommandTest.php
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters