From 1cdf9a378a699bea73c138921c8317ce258b7fa4 Mon Sep 17 00:00:00 2001 From: Jonas Regner Date: Tue, 21 May 2024 19:43:07 +0200 Subject: [PATCH] refactor: many things --- README.md | 413 +----------------- composer.json | 2 +- .../Abstracts/InfrastructureCommand.php | 16 - src/Commands/MakeAppCommand.php | 80 ---- src/Commands/MakeCollectionCommand.php | 27 +- src/Commands/MakeMiddlewareCommand.php | 23 - src/Commands/MakeMigrationCommand.php | 54 --- src/Commands/MakeNotificationCommand.php | 23 - src/Commands/MakePolicyCommand.php | 26 +- src/Commands/MakeQueryCommand.php | 26 +- src/Commands/PublishDeptracCommand.php | 21 - src/Exceptions/AppDoesNotExistsException.php | 11 - src/NameResolver.php | 116 +---- src/helper.php | 7 - stubs/App/Commands/.gitkeep | 0 stubs/App/Controllers/.gitkeep | 0 stubs/App/Filters/.gitkeep | 0 stubs/App/Jobs/.gitkeep | 0 stubs/App/Middleware/.gitkeep | 0 stubs/App/Providers/AppServiceProvider.stub | 24 - stubs/App/Queries/.gitkeep | 0 stubs/App/Requests/.gitkeep | 0 stubs/App/Resources/.gitkeep | 0 stubs/App/routes.stub | 18 - stubs/action.stub | 2 +- stubs/deptrac.yaml | 78 ---- stubs/factory.stub | 6 +- stubs/migration.create.stub | 21 - stubs/migration.stub | 18 - stubs/migration.update.stub | 22 - stubs/policy.plain.stub | 16 - stubs/policy.stub | 37 +- stubs/process.stub | 2 +- stubs/query.plain.stub | 15 - stubs/query.stub | 6 +- stubs/test.pest.stub | 7 - stubs/test.stub | 20 - stubs/test.unit.pest.stub | 5 - stubs/test.unit.stub | 16 - tests/Commands/MakeAppCommandTest.php | 78 ---- tests/Commands/MakeCollectionCommandTest.php | 41 -- tests/Commands/MakeCommandCommandTest.php | 7 - tests/Commands/MakeControllerCommandTest.php | 19 - tests/Commands/MakeJobCommandTest.php | 7 - tests/Commands/MakeMiddlewareCommandTest.php | 7 - tests/Commands/MakeMigrationCommandTest.php | 102 ----- tests/Commands/MakePolicyCommandTest.php | 38 +- tests/Commands/MakeProcessCommandTest.php | 7 - tests/Commands/MakeQueryCommandTest.php | 59 +-- tests/Commands/MakeRequestCommandTest.php | 7 - tests/Commands/MakeResourceCommandTest.php | 7 - tests/Commands/MakeRuleCommandTest.php | 7 - .../MakeServiceProviderCommandTest.php | 7 - tests/Commands/PublishDeptracCommandTest.php | 22 - tests/TestCase.php | 8 - 55 files changed, 60 insertions(+), 1521 deletions(-) delete mode 100644 src/Commands/Abstracts/InfrastructureCommand.php delete mode 100644 src/Commands/MakeAppCommand.php delete mode 100644 src/Commands/MakeMiddlewareCommand.php delete mode 100644 src/Commands/MakeMigrationCommand.php delete mode 100644 src/Commands/MakeNotificationCommand.php delete mode 100644 src/Commands/PublishDeptracCommand.php delete mode 100644 src/Exceptions/AppDoesNotExistsException.php delete mode 100644 stubs/App/Commands/.gitkeep delete mode 100644 stubs/App/Controllers/.gitkeep delete mode 100644 stubs/App/Filters/.gitkeep delete mode 100644 stubs/App/Jobs/.gitkeep delete mode 100644 stubs/App/Middleware/.gitkeep delete mode 100644 stubs/App/Providers/AppServiceProvider.stub delete mode 100644 stubs/App/Queries/.gitkeep delete mode 100644 stubs/App/Requests/.gitkeep delete mode 100644 stubs/App/Resources/.gitkeep delete mode 100644 stubs/App/routes.stub delete mode 100644 stubs/deptrac.yaml delete mode 100644 stubs/migration.create.stub delete mode 100644 stubs/migration.stub delete mode 100644 stubs/migration.update.stub delete mode 100644 stubs/policy.plain.stub delete mode 100644 stubs/query.plain.stub delete mode 100644 stubs/test.pest.stub delete mode 100644 stubs/test.stub delete mode 100644 stubs/test.unit.pest.stub delete mode 100644 stubs/test.unit.stub delete mode 100644 tests/Commands/MakeAppCommandTest.php delete mode 100644 tests/Commands/MakeMigrationCommandTest.php delete mode 100644 tests/Commands/PublishDeptracCommandTest.php diff --git a/README.md b/README.md index af5b36f..f19359f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ and "[Modularising the Monolith](https://www.youtube.com/watch?v=0Rq-yHAwYjQ&t=4 This package will help you with `beyond:make` commands to easily create classes inside your "Laravel Beyond CRUD" inspired application. -We try to implement commands as near as possible on their original `make` counterparts. In version 7 we changed the way how Laravel Beyond works. We now do no longer change Laravels default directory structure, instead we place the DDD structure inside a separate `src` directory. This ensures @@ -23,7 +22,7 @@ Install laravel-beyond with composer composer require --dev akrillia/laravel-beyond ``` -After this you need to register the namespaces inside your `composer.json`. +Register the namespaces inside your `composer.json`. ```json { // ... @@ -33,435 +32,43 @@ After this you need to register the namespaces inside your `composer.json`. "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/", "Application\\": "src/Application", - "Domain\\": "src/Domain", - "Infrastructure\\": "src/Infrastructure" + "Domain\\": "src/Domain" } }, // ... } ``` - -Now you still have to run `composer dump-autoload` and everything is set up for using Laravel Beyond commands. +Run `composer dump-autoload` and everything is set up for using Laravel Beyond commands. ## Structure ``` |- src | |- Application | | |- Admin -| | | |- Controllers | | | |- Commands -| | | |- Filters +| | | |- Controllers | | | |- Jobs -| | | |- Middleware -| | | |- Providers +| | | |- Policies +| | | |- Processes | | | |- Queries | | | |- Requests | | | |- Resources -| | | |- routes.php +| | | |- Rules | |- Domain | | |- User | | | |- Actions +| | | |- Builder | | | |- Collections -| | | |- DataTransferObjects +| | | |- DataObjects +| | | |- Enums | | | |- Events -| | | |- Exceptions | | | |- Listeners | | | |- Models | | | |- Observers -| | | |- Policies -| | | |- Rules -| | | |- States -| | | |- ValueObjects -| |- Infrastructure -| | |- User -| | | |- Factories -| | | |- Migrations -| | | |- Seeders ``` ## Usage -### Commands - -#### `beyond:make:action` - -This command will create a new action class inside your domain. - -```bash -php artisan beyond:make:action Users.CreateUserAction -``` - -**Options** - -| Name | Description | -|------------|----------------------------------------------------| -| `--force` | Create the class even if the action already exists | - ---- - -#### `beyond:make:builder` - -This command will create a new eloquent builder class inside your domain. - -```bash -php artisan beyond:make:builder Users.UserBuilder -``` - -**Options** - -| Name | Description | -|------------|--------------------------------------------------------------| -| `--force` | Create the class even if the eloquent builder already exists | - ---- - -#### `beyond:make:collection` - -This command will create a new collection class inside your domain. - -```bash -php artisan beyond:make:collection Users.UserCollection -``` - -**Options** - -| Name | Description | -|------------|--------------------------------------------------------| -| `--model=` | Will create a model related collection | -| `--force` | Create the class even if the collection already exists | - ---- - -#### `beyond:make:command` - -This command will create a new command class inside your console application. - -```bash -php artisan beyond:make:command SyncUsersCommand -``` - -**Options** - -| Name | Description | -|--------------|------------------------------------------------------| -| `--command=` | Will use given `command:name` schema for new command | -| `--force` | Create the class even if the command already exists | - ---- - -#### `beyond:make:controller` - -This command will create a new action class inside your application. - -```bash -php artisan beyond:make:controller User.Admin/UserController -``` - -**Options** - -| Name | Description | -|---------------------|--------------------------------------------------------| -| `--api` | Will overwrite an API controller | -| `-i`, `--invokable` | Generate a single method, invokable controller class. | -| `--force` | Create the class even if the controller already exists | - ---- - -#### `beyond:make:enum` - -This command will create a new enum class inside your domain. - -```bash -php artisan beyond:make:enum Users/UserStatusEnum -``` - -**Options** - -| Name | Description | -|-----------|--------------------------------------------------| -| `--force` | Create the class even if the enum already exists | - ---- - -#### `beyond:make:event` - -This command will create a new event class inside your application. - -```bash -php artisan beyond:make:event Users/UserCreatedEvent -``` - -**Options** - -| Name | Description | -|------------|---------------------------------------------------| -| `--force` | Create the class even if the event already exists | - ---- - -#### `beyond:make:dto` - -This command will create a new data transfer object class inside your domain. - -```bash -php artisan beyond:make:dto Users/UserData -``` - -**Options** - -| Name | Description | -|-----------|------------------------------------------------------------------| -| `--force` | Create the class even if the data transfer object already exists | - ---- - -#### `beyond:make:dto-factory Admin/User/UserDataFactory` - -This command will create a new data transfer object factory class inside your application. - -```bash -php artisan beyond:make:dto-factory Admin/User/UserDataFactory -``` - -**Options** - -| Name | Description | -|-----------|---------------------------------------------------------| -| `--dto` | Generate a DTO factory for the given DTO | -| `--force` | Create the class even if the DTO factory already exists | - ---- - -#### `beyond:make:job` - -This command will create a new job class inside your application. - -```bash -php artisan beyond:make:job Admin/Users/SyncUsersJob -``` - -**Options** - -| Name | Description | -|-----------|-------------------------------------------------| -| `--force` | Create the class even if the job already exists | - ---- - -#### `beyond:make:listener` - -This command will create a new listener class inside your domain. - -```bash -php artisan beyond:make:listener Users/UserCreatedListener -``` - -**Options** - -| Name | Description | -|-----------|------------------------------------------------------| -| `--force` | Create the class even if the listener already exists | - ---- - -#### `beyond:make:middleware` - -This command will create a new middleware class inside your application. - -```bash -php artisan beyond:make:middleware Admin/Users/IdentifyUserMiddleware -``` - -**Options** - -| Name | Description | -|-------------|--------------------------------------------------------| -| `--force` | Create the class even if the middleware already exists | -| `--support` | Will create a middleware in Support namespace | - ---- - -#### `beyond:make:model` - -This command will create a new model class inside your domain. - -```bash -php artisan beyond:make:model Users/User -``` - -**Options** - -| Name | Description | -|---------------------|---------------------------------------------------| -| `-f`, `--factory` | Will create a factory for this model | -| `-m`, `--migration` | Will create a migration for this model | -| `--force` | Create the class even if the model already exists | - ---- - -#### `beyond:make:observer` - -This command will create a new observer class inside your domain. - -```bash -php artisan beyond:make:observer Users/UserObserver -``` - -**Options** - -| Name | Description | -|------------|------------------------------------------------------| -| `--force` | Create the class even if the observer already exists | - ---- - -#### `beyond:make:policy` - -This command will create a new policy class inside your domain. - -```bash -php artisan beyond:make:policy Users/UserPolicy -``` - -**Options** - -| Name | Description | -|------------|----------------------------------------------------| -| `--model=` | Will create a policy for the given model | -| `--force` | Create the class even if the policy already exists | - ---- - -#### `beyond:make:query` __requires spatie/laravel-query-builder__ - -This command will create a new query class inside your domain. - -```bash -php artisan beyond:make:query Admin/Users/UserIndexQuery -``` - -**Options** - -| Name | Description | -|-----------|-----------------------------------------------------------| -| `--force` | Create the class even if the query builder already exists | - ---- - -#### `beyond:make:request` - -This command will create a new request class inside your application. - -```bash -php artisan beyond:make:request Admin/Users/CreateUserRequest -``` - -**Options** - -| Name | Description | -|-----------|-----------------------------------------------------| -| `--force` | Create the class even if the request already exists | - ---- - -#### `beyond:make:resource` - -This command will create a new resource class inside your application. - -```bash -php artisan beyond:make:resource Admin/Users/UserResource -``` - -**Options** - -| Name | Description | -|----------------|------------------------------------------------------| -| `--collection` | Will create a collection | -| `--force` | Create the class even if the resource already exists | - ---- - -#### `beyond:make:route` - -This command will create a new route file inside your routes folder. - -```bash -php artisan beyond:make:route Users -``` - -**Options** - -| Name | Description | -|-----------|---------------------------------------------------| -| `--force` | Create the class even if the route already exists | - ---- - -#### `beyond:make:rule` - -This command will create a new rule class inside your application. - -```bash -php artisan beyond:make:rule Admin/Users/IsAdminRule -``` - -**Options** - -| Name | Description | -|-------------|--------------------------------------------------| -| `--force` | Create the class even if the rule already exists | -| `--support` | Will create a middleware in Support namespace | - ---- - -#### `beyond:make:trait` - -This command will create a new trait class inside your application. - -```bash -php artisan beyond:make:trait HasActivationCodeTrait -``` - -**Options** - -| Name | Description | -|-------------|---------------------------------------------------| -| `--force` | Create the trait even if the trait already exists | - ---- - -#### `beyond:make:provider` - -This command will create a new service provider class. - -```bash -php artisan beyond:make:provider UserServiceProvider -``` - -**Options** - -| Name | Description | -|-----------|--------------------------------------------------------------| -| `--force` | Create the class even if the service provider already exists | - ---- - -#### `beyond:setup` - -This command will setup a default Laravel installation into a DDD structure. - -```bash -php artisan beyond:setup -``` - -**Options** - -| Name | Description | -|-----------------|---------------------------------------------------| -| `--force` | Create the class even if the class already exists | -| `--skip-delete` | Will skip the deletion of app directory | - ---- ## ToDo ### Commands diff --git a/composer.json b/composer.json index 1f3c2f3..65707fd 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,7 @@ "suggest": { "spatie/laravel-query-builder": "This package is required for Queries.", "spatie/laravel-data": "This package is required for DataTransferObjects.", - "spatie/laravel-queueable-action": "This package is required for queueable Actions.", + "spatie/laravel-queueable-action": "This package is required for queueable actions.", "qossmic/deptrac-shim": "This package can help you enforce architectural decisions by Laraval Beyond." }, "config": { diff --git a/src/Commands/Abstracts/InfrastructureCommand.php b/src/Commands/Abstracts/InfrastructureCommand.php deleted file mode 100644 index 47918ae..0000000 --- a/src/Commands/Abstracts/InfrastructureCommand.php +++ /dev/null @@ -1,16 +0,0 @@ -argument('name'))->studly()->ucfirst()->value(); - $force = (bool) $this->option('force'); - $full = (bool) $this->option('full'); - - $this->copyDirectoryAction->execute( - __DIR__.'/../../stubs/App', - beyond_app_path($app), - $force, - ); - - $this->moveAndRefactorAppFiles($app, $force); - - $this->deleteGitKeep($app, ! $full); - - $this->components->info("{$app} app created successfully."); - } - - private function moveAndRefactorAppFiles(string $app, bool $force = false): void - { - $files = [ - 'Providers/AppServiceProvider.stub' => "Providers/{$app}ServiceProvider.php", - 'routes.stub' => 'routes.php', - ]; - - foreach ($files as $from => $to) { - $this->moveAndRefactorFileAction->execute( - beyond_app_path("$app/$from"), - beyond_app_path("$app/$to"), - [ - '{{ module }}' => $app, - ], - $force - ); - } - } - - private function deleteGitKeep(string $app, bool $minimal = false): void - { - $files = Finder::create() - ->files() - ->ignoreDotFiles(false) - ->name('.gitkeep') - ->in(beyond_app_path($app)); - - foreach ($files as $file) { - $this->deletePathAction->execute( - $minimal - ? $file->getPath() - : $file->getPathname() - ); - } - } -} diff --git a/src/Commands/MakeCollectionCommand.php b/src/Commands/MakeCollectionCommand.php index 7f4b55a..453f524 100644 --- a/src/Commands/MakeCollectionCommand.php +++ b/src/Commands/MakeCollectionCommand.php @@ -3,43 +3,22 @@ namespace AkrilliA\LaravelBeyond\Commands; use AkrilliA\LaravelBeyond\Commands\Abstracts\DomainCommand; -use AkrilliA\LaravelBeyond\NameResolver; use AkrilliA\LaravelBeyond\Type; final class MakeCollectionCommand extends DomainCommand { - protected $signature = 'beyond:make:collection {name} {--model=} {--force}'; + protected $signature = 'beyond:make:collection {name} {--force}'; protected $description = 'Make a new collection'; protected function getStub(): string { - return $this->hasOption('model') - ? 'collection.stub' - : 'collection.plain.stub'; + return 'collection.stub'; + } public function getType(): Type { return new Type('Collection'); } - - public function setup(NameResolver $fqn): void - { - if ($model = $this->option('model')) { - $command = new MakeModelCommand(); - $fqn = $command->getNameResolver($fqn->getAppOrDomain().'.'.$model); - - $this->mergePlaceholders([ - '{{ modelNamespace }}' => $fqn->getNamespace(), - '{{ modelClassName }}' => $fqn->getClassName(), - ]); - - $this->addOnSuccess(function (string $namespace, string $className) use ($fqn) { - $this->call(MakeModelCommand::class, [ - 'name' => $fqn->getCommandNameArgument(), - ]); - }); - } - } } diff --git a/src/Commands/MakeMiddlewareCommand.php b/src/Commands/MakeMiddlewareCommand.php deleted file mode 100644 index bd0fba8..0000000 --- a/src/Commands/MakeMiddlewareCommand.php +++ /dev/null @@ -1,23 +0,0 @@ -stub; - } - - public function getType(): Type - { - return new Type('Database/Migration', 'Migration'); - } - - public function getFileNameTemplate(): string - { - $now = new \DateTime(); - - return $now->format('Y_m_d_His').'_%s.php'; - } - - public function setup(NameResolver $fqn): void - { - $name = Str::snake($fqn->getClassName()); - - [$table, $create] = TableGuesser::guess($name); - - if (is_null($table)) { - $this->stub = 'migration.stub'; - } elseif ($create) { - $this->stub = 'migration.create.stub'; - } else { - $this->stub = 'migration.update.stub'; - } - - $this->mergePlaceholders([ - '{{ table }}' => $table, - ]); - } -} diff --git a/src/Commands/MakeNotificationCommand.php b/src/Commands/MakeNotificationCommand.php deleted file mode 100644 index 67b2a86..0000000 --- a/src/Commands/MakeNotificationCommand.php +++ /dev/null @@ -1,23 +0,0 @@ -option('model') - ? 'policy.stub' - : 'policy.plain.stub'; + return 'policy.stub'; } public function getType(): Type { return new Type('Policy'); } - - public function setup(NameResolver $fqn): void - { - if ($model = $this->option('model')) { - $command = new MakeModelCommand(); - $fqn = $command->getNameResolver($fqn->getAppOrDomain().'.'.$model); - - $this->mergePlaceholders([ - '{{ modelNamespace }}' => $fqn->getNamespace(), - '{{ modelClassName }}' => $fqn->getClassName(), - '{{ modelVariable }}' => Str::camel($fqn->getClassName()), - ]); - } - } } diff --git a/src/Commands/MakeQueryCommand.php b/src/Commands/MakeQueryCommand.php index 22cba23..869f4d1 100644 --- a/src/Commands/MakeQueryCommand.php +++ b/src/Commands/MakeQueryCommand.php @@ -3,43 +3,21 @@ namespace AkrilliA\LaravelBeyond\Commands; use AkrilliA\LaravelBeyond\Commands\Abstracts\ApplicationCommand; -use AkrilliA\LaravelBeyond\NameResolver; use AkrilliA\LaravelBeyond\Type; final class MakeQueryCommand extends ApplicationCommand { - protected $signature = 'beyond:make:query {name} {--model=} {--force}'; + protected $signature = 'beyond:make:query {name} {--force}'; protected $description = 'Make a new query'; protected function getStub(): string { - return $this->option('model') - ? 'query.stub' - : 'query.plain.stub'; + return 'query.stub'; } public function getType(): Type { return new Type('Query'); } - - public function setup(NameResolver $nameResolver): void - { - if ($model = $this->option('model')) { - $command = new MakeModelCommand(); - $fqn = $command->getNameResolver($nameResolver->getAppOrDomain().'.'.$model); - - $this->mergePlaceholders([ - '{{ modelNamespace }}' => $fqn->getNamespace(), - '{{ modelClassName }}' => $fqn->getClassName(), - ]); - - $this->addOnSuccess(function (string $namespace, string $className) use ($fqn) { - $this->call(MakeModelCommand::class, [ - 'name' => $fqn->getCommandNameArgument(), - ]); - }); - } - } } diff --git a/src/Commands/PublishDeptracCommand.php b/src/Commands/PublishDeptracCommand.php deleted file mode 100644 index 1ae1732..0000000 --- a/src/Commands/PublishDeptracCommand.php +++ /dev/null @@ -1,21 +0,0 @@ -option('force') - ); - } -} diff --git a/src/Exceptions/AppDoesNotExistsException.php b/src/Exceptions/AppDoesNotExistsException.php deleted file mode 100644 index 084f2e8..0000000 --- a/src/Exceptions/AppDoesNotExistsException.php +++ /dev/null @@ -1,11 +0,0 @@ -name); - $numParts = count($parts); - $commandType = match (true) { - $this->command instanceof ApplicationCommand => 'APP', - $this->command instanceof DomainCommand => 'DOMAIN', - $this->command instanceof InfrastructureCommand => 'INFRASTRUCTURE', - default => 'UNKNOWN' - }; - - if ($numParts === 1) { - $this->appOrDomain = $this->askForAppOrDomainName($commandType); - } elseif ($numParts === 2 || ($numParts === 3 && $commandType === 'APP')) { - $appOrDomain = $parts[0]; - - if ($commandType === 'APP' && ! $this->isExistingApp($appOrDomain)) { - throw new AppDoesNotExistsException($parts[0]); - } - - if ($numParts === 3 && $commandType === 'APP') { - $this->appOrDomain = $appOrDomain; - $this->module = $parts[1]; - $this->setDirectoryAndClassName($parts[2]); - } else { - $this->appOrDomain = $appOrDomain; - $this->setDirectoryAndClassName($parts[1]); - } - } else { - throw new InvalidNameException($this->name); + $name = new Stringable($this->name); + $this->appOrDomain = $name->contains('.') + ? $name->before('.')->toString() + : null; + $this->setDirectoryAndClassName($name->after('.')); + + if (! $this->appOrDomain) { + $this->appOrDomain = $this->askForAppOrDomainName(); } $this->namespace = sprintf( - $this->command->getNamespaceTemplate().'%s%s', + $this->command->getNamespaceTemplate().'%s', $this->appOrDomain, - $this->module ? '\\'.$this->module.'\\' : '', $this->command->getType()->getNamespace(), $this->directory ? '\\'.$this->directory : '', ); @@ -106,68 +80,26 @@ private function init(): void ); } - private function askForAppOrDomainName(string $commandType): string + private function askForAppOrDomainName(): string { - $cases = match ($commandType) { - 'APP' => ['app', beyond_get_choices(base_path('src/Application')), 'askForAppName'], - 'DOMAIN' => ['domain', beyond_get_choices(base_path('src/Domain')), 'askForDomainName'], - 'INFRASTRUCTURE' => ['infrastructure', beyond_get_choices('src/Infrastructure'), 'askForDomainName'], - default => [] + $cases = match (true) { + $this->command instanceof ApplicationCommand => ['app', beyond_get_choices(base_path('src/Application'))], + $this->command instanceof DomainCommand => ['domain', beyond_get_choices(base_path('src/Domain'))], + default => [] }; - $question = sprintf('On which %s do you want to add your %s', $cases[0], $this->command->getType()->getName()); - - return $this->{$cases[2]}($question, $cases[1]); - } - - /** - * @param array $options - */ - private function askForAppName(string $question, array $options): string - { - return search( - $question, - function (string $value) use ($options) { - if ($value !== '') { - return collect($options)->filter(fn ($o) => Str::contains($o, $value, true)); - } - - return $options; - }, - validate: function (string $value) use ($options) { - if (! in_array($value, $options, true)) { - return 'The given app does not exist.'; - } - } - ); - } - - /** - * @param array $options - */ - private function askForDomainName(string $question, array $options): string - { return suggest( - $question, - function (string $value) use ($options) { - return collect($options)->filter(fn ($o) => Str::contains($o, $value, true))->toArray(); - } - ); + sprintf('On which %s do you want to add your %s', $cases[0], $this->command->getType()->getName()), + function (string $value) use ($cases) { + return collect($cases[1])->filter(fn ($o) => Str::contains($o, $value, true))->toArray(); + }); } - private function isExistingApp(string $app): bool + private function setDirectoryAndClassName(Stringable $name): void { - $apps = beyond_get_choices(base_path('src/Application')); - - return in_array($app, $apps, true); - } - - private function setDirectoryAndClassName(string $name): void - { - $parts = explode('/', $name); - - $this->className = array_pop($parts); - - $this->directory = implode('\\', $parts); + $this->directory = $name->contains('/') + ? $name->beforeLast('/')->replace('/', '\\')->toString() + : ''; + $this->className = $name->afterLast('/')->toString(); } } diff --git a/src/helper.php b/src/helper.php index b56f837..aabcfff 100644 --- a/src/helper.php +++ b/src/helper.php @@ -27,13 +27,6 @@ function beyond_domain_path(string $path = ''): string } } -if (! function_exists('beyond_infra_path')) { - function beyond_infra_path(string $path = ''): string - { - return beyond_path('Infrastructure/'.ltrim($path, '/')); - } -} - if (! function_exists('beyond_copy_stub')) { /** * @param array $refactor diff --git a/stubs/App/Commands/.gitkeep b/stubs/App/Commands/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Controllers/.gitkeep b/stubs/App/Controllers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Filters/.gitkeep b/stubs/App/Filters/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Jobs/.gitkeep b/stubs/App/Jobs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Middleware/.gitkeep b/stubs/App/Middleware/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Providers/AppServiceProvider.stub b/stubs/App/Providers/AppServiceProvider.stub deleted file mode 100644 index 5af3ab8..0000000 --- a/stubs/App/Providers/AppServiceProvider.stub +++ /dev/null @@ -1,24 +0,0 @@ -loadRoutesFrom(__DIR__ . '/../routes.php'); - } -} diff --git a/stubs/App/Queries/.gitkeep b/stubs/App/Queries/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Requests/.gitkeep b/stubs/App/Requests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/Resources/.gitkeep b/stubs/App/Resources/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/stubs/App/routes.stub b/stubs/App/routes.stub deleted file mode 100644 index 81fa9bf..0000000 --- a/stubs/App/routes.stub +++ /dev/null @@ -1,18 +0,0 @@ - 'api', - 'middleware' => 'api' -], function () { - // -}); - -// Web Routes -Route::group([ - 'middleware' => 'web' -], function () { - // -}); diff --git a/stubs/action.stub b/stubs/action.stub index 7c0f407..2968060 100644 --- a/stubs/action.stub +++ b/stubs/action.stub @@ -2,7 +2,7 @@ namespace {{ namespace }}; -final class {{ className }} +final readonly class {{ className }} { public function execute(): mixed { diff --git a/stubs/deptrac.yaml b/stubs/deptrac.yaml deleted file mode 100644 index e870161..0000000 --- a/stubs/deptrac.yaml +++ /dev/null @@ -1,78 +0,0 @@ -deptrac: - paths: - - ./modules - exclude_files: - - '#*Test\.php#' - layers: - - - name: Action - collectors: - - - type: className - value: .*\\Domain\\Actions\\.* - - - name: Builder - collectors: - - - type: className - value: .*\\Domain\\Builders\\.* - - - name: Collection - collectors: - - - type: className - value: .*\\Domain\\Collections\\.* - - - name: DataObject - collectors: - - - type: className - value: .*\\Domain\\DataObjects\\.* - - - name: Controller - collectors: - - - type: className - value: .*\\App\\Controllers\\.* - - - name: Job - collectors: - - - type: className - value: .*\\App\\Jobs\\.* - - - name: Model - collectors: - - - type: className - value: .*\\Domain\\Models\\.* - - - name: Process - collectors: - - - type: className - value: .*\\App\\Processes\\.* - - - name: Query - collectors: - - - type: className - value: .*\\App\\Queries\\.* - ruleset: - Controller: - - Job - - Process - - Query - Process: - - Action - - DataObject - Action: - - DataObject - - Model - DataObject: ~ - Model: - - Builder - - Collection - Builder: ~ - Query: - - Model \ No newline at end of file diff --git a/stubs/factory.stub b/stubs/factory.stub index b175ef1..4b34599 100644 --- a/stubs/factory.stub +++ b/stubs/factory.stub @@ -3,17 +3,15 @@ namespace {{ namespace }}; use Illuminate\Database\Eloquent\Factories\Factory; -use Domain\{{ namespace }}\Models\{{ model }}; /** * @extends Factory<{{ model }}> */ final class {{ model }}Factory extends Factory { + // protected $model = Model::class; - protected $model = {{ model }}::class; - - public function definition() + public function definition(): array { return [ // diff --git a/stubs/migration.create.stub b/stubs/migration.create.stub deleted file mode 100644 index 089061d..0000000 --- a/stubs/migration.create.stub +++ /dev/null @@ -1,21 +0,0 @@ -id(); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('{{ table }}'); - } -}; \ No newline at end of file diff --git a/stubs/migration.stub b/stubs/migration.stub deleted file mode 100644 index 8e234cc..0000000 --- a/stubs/migration.stub +++ /dev/null @@ -1,18 +0,0 @@ -get('/'); - - $response->assertStatus(200); -}); \ No newline at end of file diff --git a/stubs/test.stub b/stubs/test.stub deleted file mode 100644 index 59215c9..0000000 --- a/stubs/test.stub +++ /dev/null @@ -1,20 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } -} \ No newline at end of file diff --git a/stubs/test.unit.pest.stub b/stubs/test.unit.pest.stub deleted file mode 100644 index e34044c..0000000 --- a/stubs/test.unit.pest.stub +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); \ No newline at end of file diff --git a/stubs/test.unit.stub b/stubs/test.unit.stub deleted file mode 100644 index 358cb1d..0000000 --- a/stubs/test.unit.stub +++ /dev/null @@ -1,16 +0,0 @@ -assertTrue(true); - } -} \ No newline at end of file diff --git a/tests/Commands/MakeAppCommandTest.php b/tests/Commands/MakeAppCommandTest.php deleted file mode 100644 index 6867444..0000000 --- a/tests/Commands/MakeAppCommandTest.php +++ /dev/null @@ -1,78 +0,0 @@ -artisan('beyond:make:app Admin'); - - $file = beyond_app_path('Admin/Providers/AdminServiceProvider.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ module }}', $contents); - } - - public function testCanMakeSnakeCaseModule(): void - { - $this->artisan('beyond:make:app SuperAdmin'); - - $file = beyond_app_path('SuperAdmin/Providers/SuperAdminServiceProvider.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ module }}', $contents); - } - - public function testCanMakeModuleUsingForce(): void - { - $this->artisan('beyond:make:app Admin'); - - $file = beyond_app_path('Admin/Providers/AdminServiceProvider.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ module }}', $contents); - - $code = $this->artisan('beyond:make:app Admin --force'); - - $code->assertOk(); - } - - // public function testCanMakeFullModule(): void - // { - // $this->artisan('beyond:make:app Admin --full'); - // - // $files = $this->getPaths(); - // - // foreach ($files as $file) { - // match (Str::contains($file, '.')) { - // true => $this->assertFileExists($file), - // false => $this->assertDirectoryExists($file), - // }; - // } - // } - - // public function testCanMakeFullModuleUsingForce(): void - // { - // $this->artisan('beyond:make:module User --full'); - // - // $files = $this->getPaths(); - // - // foreach ($files as $file) { - // match (Str::contains($file, '.')) { - // true => $this->assertFileExists($file), - // false => $this->assertDirectoryExists($file), - // }; - // } - // - // $code = $this->artisan('beyond:make:app Admin --full --force'); - // - // $code->assertOk(); - // } -} diff --git a/tests/Commands/MakeCollectionCommandTest.php b/tests/Commands/MakeCollectionCommandTest.php index 68d9277..d5eead7 100644 --- a/tests/Commands/MakeCollectionCommandTest.php +++ b/tests/Commands/MakeCollectionCommandTest.php @@ -33,45 +33,4 @@ public function testCanMakeCollectionUsingForce(): void $code->assertOk(); } - - public function testCanMakeCollectionWithModel(): void - { - $this->artisan('beyond:make:collection User.UserCollection --model=User'); - - $file = beyond_domain_path('User/Collections/UserCollection.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - } - - public function testCanMakeCollectionWithModelUsingForce(): void - { - $this->artisan('beyond:make:collection User.UserCollection --model=User'); - - $file = beyond_domain_path('User/Collections/UserCollection.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $code = $this->artisan('beyond:make:collection User.UserCollection --model=User --force'); - $code->assertOk(); - } } diff --git a/tests/Commands/MakeCommandCommandTest.php b/tests/Commands/MakeCommandCommandTest.php index 7d2f22c..06a8d2d 100644 --- a/tests/Commands/MakeCommandCommandTest.php +++ b/tests/Commands/MakeCommandCommandTest.php @@ -6,13 +6,6 @@ class MakeCommandCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeCommand(): void { $this->artisan('beyond:make:command User.CreateUser'); diff --git a/tests/Commands/MakeControllerCommandTest.php b/tests/Commands/MakeControllerCommandTest.php index ccae5bf..fa3ba7c 100644 --- a/tests/Commands/MakeControllerCommandTest.php +++ b/tests/Commands/MakeControllerCommandTest.php @@ -6,13 +6,6 @@ class MakeControllerCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeController(): void { $this->artisan('beyond:make:controller User.UserController'); @@ -25,18 +18,6 @@ public function testCanMakeController(): void $this->assertStringNotContainsString('{{ className }}', $contents); } - public function testCanMakeModuleController(): void - { - $this->artisan('beyond:make:controller User.User.UserController'); - - $file = beyond_app_path('User/User/Controllers/UserController.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - } - public function testCanMakeControllerUsingForce(): void { $this->artisan('beyond:make:controller User.UserController'); diff --git a/tests/Commands/MakeJobCommandTest.php b/tests/Commands/MakeJobCommandTest.php index 0b541c9..954a11e 100644 --- a/tests/Commands/MakeJobCommandTest.php +++ b/tests/Commands/MakeJobCommandTest.php @@ -6,13 +6,6 @@ class MakeJobCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeJob(): void { $this->artisan('beyond:make:job User.CancelTrials'); diff --git a/tests/Commands/MakeMiddlewareCommandTest.php b/tests/Commands/MakeMiddlewareCommandTest.php index 081b054..7d6bd46 100644 --- a/tests/Commands/MakeMiddlewareCommandTest.php +++ b/tests/Commands/MakeMiddlewareCommandTest.php @@ -6,13 +6,6 @@ class MakeMiddlewareCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeMiddleware(): void { $this->artisan('beyond:make:middleware User.SetLocale'); diff --git a/tests/Commands/MakeMigrationCommandTest.php b/tests/Commands/MakeMigrationCommandTest.php deleted file mode 100644 index d32508b..0000000 --- a/tests/Commands/MakeMigrationCommandTest.php +++ /dev/null @@ -1,102 +0,0 @@ -artisan('beyond:make:migration User.SimpleMigration'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_SimpleMigration.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ table }}', $contents); - $this->assertStringNotContainsString('Schema::', $contents); - } - - public function testCanMakeMigrationUsingForce(): void - { - $this->artisan('beyond:make:migration User.SimpleMigration'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_SimpleMigration.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ table }}', $contents); - $this->assertStringNotContainsString('Schema::', $contents); - - $code = $this->artisan('beyond:make:migration User.SimpleMigration --force'); - - $code->assertOk(); - } - - public function testCanMakeCreateMigration(): void - { - $this->artisan('beyond:make:migration User.CreateUsersTable'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_CreateUsersTable.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringContainsString('Schema::create', $contents); - } - - public function testCanMakeCreateMigrationUsingForce(): void - { - $this->artisan('beyond:make:migration User.CreateUsersTable'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_CreateUsersTable.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringContainsString('Schema::create', $contents); - - $code = $this->artisan('beyond:make:migration User.CreateUsersTable --force'); - - $code->assertOk(); - } - - public function testCanMakeUpdateMigration(): void - { - $this->artisan('beyond:make:migration User.AddStatusToUsersTable'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_AddStatusToUsersTable.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ table }}', $contents); - $this->assertStringContainsString('Schema::table', $contents); - } - - public function testCanMakeUpdateMigrationUsingForce(): void - { - $this->artisan('beyond:make:migration User.AddStatusToUsersTable'); - - $now = new \DateTime(); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_AddStatusToUsersTable.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ table }}', $contents); - $this->assertStringContainsString('Schema::table', $contents); - - $code = $this->artisan('beyond:make:migration User.AddStatusToUsersTable --force'); - - $code->assertOk(); - } -} diff --git a/tests/Commands/MakePolicyCommandTest.php b/tests/Commands/MakePolicyCommandTest.php index 90fe261..ee8433d 100644 --- a/tests/Commands/MakePolicyCommandTest.php +++ b/tests/Commands/MakePolicyCommandTest.php @@ -10,7 +10,7 @@ public function testCanMakePolicy(): void { $this->artisan('beyond:make:policy User.UserPolicy'); - $file = beyond_domain_path('User/Policies/UserPolicy.php'); + $file = beyond_app_path('User/Policies/UserPolicy.php'); $contents = file_get_contents($file); $this->assertFileExists($file); @@ -22,7 +22,7 @@ public function testCanMakePolicyUsingForce(): void { $this->artisan('beyond:make:policy User.UserPolicy'); - $file = beyond_domain_path('User/Policies/UserPolicy.php'); + $file = beyond_app_path('User/Policies/UserPolicy.php'); $contents = file_get_contents($file); $this->assertFileExists($file); @@ -33,38 +33,4 @@ public function testCanMakePolicyUsingForce(): void $code->assertOk(); } - - public function testCanMakePolicyWithModel(): void - { - $this->artisan('beyond:make:policy User.UserPolicy --model=User'); - - $file = beyond_domain_path('User/Policies/UserPolicy.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - $this->assertStringNotContainsString('{{ modelNamespace }}', $contents); - $this->assertStringNotContainsString('{{ modelClassName }}', $contents); - $this->assertStringNotContainsString('{{ modelVariable }}', $contents); - } - - public function testCanMakePolicyWithModelUsingForce(): void - { - $this->artisan('beyond:make:policy User.UserPolicy --model=User'); - - $file = beyond_domain_path('User/Policies/UserPolicy.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - $this->assertStringNotContainsString('{{ modelNamespace }}', $contents); - $this->assertStringNotContainsString('{{ modelClassName }}', $contents); - $this->assertStringNotContainsString('{{ modelVariable }}', $contents); - - $code = $this->artisan('beyond:make:policy User.UserPolicy --model=User --force'); - - $code->assertOk(); - } } diff --git a/tests/Commands/MakeProcessCommandTest.php b/tests/Commands/MakeProcessCommandTest.php index 1aa0287..b964457 100644 --- a/tests/Commands/MakeProcessCommandTest.php +++ b/tests/Commands/MakeProcessCommandTest.php @@ -6,13 +6,6 @@ class MakeProcessCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeAction(): void { $this->artisan('beyond:make:process User.AdminStoreUserProcess'); diff --git a/tests/Commands/MakeQueryCommandTest.php b/tests/Commands/MakeQueryCommandTest.php index d0e062e..6d1dbaf 100644 --- a/tests/Commands/MakeQueryCommandTest.php +++ b/tests/Commands/MakeQueryCommandTest.php @@ -6,18 +6,11 @@ class MakeQueryCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeQuery(): void { - $this->artisan('beyond:make:query User.UserIndexQuery'); + $this->artisan('beyond:make:query User.IndexUserQuery'); - $file = beyond_app_path('User/Queries/UserIndexQuery.php'); + $file = beyond_app_path('User/Queries/IndexUserQuery.php'); $contents = file_get_contents($file); $this->assertFileExists($file); @@ -27,58 +20,16 @@ public function testCanMakeQuery(): void public function testCanMakeQueryUsingForce(): void { - $this->artisan('beyond:make:query User.UserIndexQuery'); - - $file = beyond_app_path('User/Queries/UserIndexQuery.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $code = $this->artisan('beyond:make:query User.UserIndexQuery --force'); - - $code->assertOk(); - } - - public function testCanMakeQueryWithModel(): void - { - $this->artisan('beyond:make:query User.UserIndexQuery --model=User'); - - $file = beyond_app_path('User/Queries/UserIndexQuery.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - } - - public function testCanMakeQueryWithModelUsingForce(): void - { - $this->artisan('beyond:make:query User.UserIndexQuery --model=User'); - - $file = beyond_app_path('User/Queries/UserIndexQuery.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); + $this->artisan('beyond:make:query User.IndexUserQuery'); - $file = beyond_domain_path('User/Models/User.php'); + $file = beyond_app_path('User/Queries/IndexUserQuery.php'); $contents = file_get_contents($file); $this->assertFileExists($file); $this->assertStringNotContainsString('{{ namespace }}', $contents); $this->assertStringNotContainsString('{{ className }}', $contents); - $code = $this->artisan('beyond:make:query User.UserIndexQuery --model=User --force'); + $code = $this->artisan('beyond:make:query User.IndexUserQuery --force'); $code->assertOk(); } diff --git a/tests/Commands/MakeRequestCommandTest.php b/tests/Commands/MakeRequestCommandTest.php index e70ebf6..2c81657 100644 --- a/tests/Commands/MakeRequestCommandTest.php +++ b/tests/Commands/MakeRequestCommandTest.php @@ -6,13 +6,6 @@ class MakeRequestCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeRequest(): void { $this->artisan('beyond:make:request User.StoreUserRequest'); diff --git a/tests/Commands/MakeResourceCommandTest.php b/tests/Commands/MakeResourceCommandTest.php index 8e8c559..b4c3117 100644 --- a/tests/Commands/MakeResourceCommandTest.php +++ b/tests/Commands/MakeResourceCommandTest.php @@ -6,13 +6,6 @@ class MakeResourceCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeResource(): void { $this->artisan('beyond:make:resource User.UserResource'); diff --git a/tests/Commands/MakeRuleCommandTest.php b/tests/Commands/MakeRuleCommandTest.php index 6f7eafa..4c7e9d1 100644 --- a/tests/Commands/MakeRuleCommandTest.php +++ b/tests/Commands/MakeRuleCommandTest.php @@ -6,13 +6,6 @@ class MakeRuleCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeRule(): void { $this->artisan('beyond:make:rule User.UniqueUser'); diff --git a/tests/Commands/MakeServiceProviderCommandTest.php b/tests/Commands/MakeServiceProviderCommandTest.php index 6069fb3..76ff3d4 100644 --- a/tests/Commands/MakeServiceProviderCommandTest.php +++ b/tests/Commands/MakeServiceProviderCommandTest.php @@ -6,13 +6,6 @@ class MakeServiceProviderCommandTest extends TestCase { - protected function setUp(): void - { - parent::setUp(); - - $this->artisan('beyond:make:app User'); - } - public function testCanMakeProvider(): void { $this->artisan('beyond:make:provider User.UserServiceProvider'); diff --git a/tests/Commands/PublishDeptracCommandTest.php b/tests/Commands/PublishDeptracCommandTest.php deleted file mode 100644 index 9c978c5..0000000 --- a/tests/Commands/PublishDeptracCommandTest.php +++ /dev/null @@ -1,22 +0,0 @@ -artisan('beyond:publish:deptrac'); - - $this->assertFileExists(base_path('deptrac.yaml')); - } - - public function testCanPublishDeptracUsingForce(): void - { - $this->artisan('beyond:publish:deptrac --force'); - - $this->assertFileExists(base_path('deptrac.yaml')); - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php index 29037b5..3e83b07 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -18,17 +18,9 @@ protected function tearDown(): void { parent::tearDown(); - $this->removeFile(base_path('deptrac.yaml')); $this->removeDirectory(beyond_path()); } - private function removeFile(string $file): void - { - if (is_file($file)) { - unlink($file); - } - } - private function removeDirectory(string $directory): void { if (! is_dir($directory)) {