diff --git a/src/Commands/MakeModelCommand.php b/src/Commands/MakeModelCommand.php index b3e3791..5079f7a 100644 --- a/src/Commands/MakeModelCommand.php +++ b/src/Commands/MakeModelCommand.php @@ -9,7 +9,7 @@ final class MakeModelCommand extends DomainCommand { - protected $signature = 'beyond:make:model {name} {--f|factory} {--m|migration} {--force}'; + protected $signature = 'beyond:make:model {name} {--force}'; protected $description = 'Make a new model'; @@ -22,33 +22,4 @@ public function getType(): Type { return new Type('Model'); } - - public function setup(NameResolver $nameResolver): void - { - if ($this->option('migration')) { - $command = new MakeMigrationCommand(); - $fqn = $command->getNameResolver($nameResolver->getAppOrDomain().'.create_fake_table'); - - $this->addOnSuccess(function (string $namespace, string $className) use ($fqn) { - $this->call(MakeMigrationCommand::class, [ - 'name' => $fqn->getAppOrDomain().'.create_'.Str::of($className)->pluralStudly()->lower().'_table', - ]); - }); - - // Add MakeFactoryCommand! - // if ($this->option('factory')) { - // $fileName = $className.'Factory'; - // - // beyond_copy_stub( - // 'factory.stub', - // base_path()."/modules/$module/Infrastructure/factories/$fileName.php", - // [ - // '{{ namespace }}' => $namespace, - // '{{ model }}' => $fileName, - // ], - // $force - // ); - // } - } - } } diff --git a/tests/Commands/MakeMiddlewareCommandTest.php b/tests/Commands/MakeMiddlewareCommandTest.php deleted file mode 100644 index 7d6bd46..0000000 --- a/tests/Commands/MakeMiddlewareCommandTest.php +++ /dev/null @@ -1,36 +0,0 @@ -artisan('beyond:make:middleware User.SetLocale'); - - $file = beyond_app_path('User/Middleware/SetLocale.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - } - - public function testCanMakeMiddlewareUsingForce(): void - { - $this->artisan('beyond:make:middleware User.SetLocale'); - - $file = beyond_app_path('User/Middleware/SetLocale.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $code = $this->artisan('beyond:make:middleware User.SetLocale --force'); - - $code->assertOk(); - } -} diff --git a/tests/Commands/MakeModelCommandTest.php b/tests/Commands/MakeModelCommandTest.php index 76eff9f..c9cc494 100644 --- a/tests/Commands/MakeModelCommandTest.php +++ b/tests/Commands/MakeModelCommandTest.php @@ -33,96 +33,4 @@ public function testCanMakeModelUsingForce(): void $code->assertOk(); } - - public function testCanMakeModelWithFactory(): void - { - $this->markTestSkipped('Not implemented yet!'); - - /* @phpstan-ignore-next-line */ - $this->artisan('beyond:make:model User.User --factory'); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_infra_path('User/Infrastructure/Factories/UserFactory.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ model }}', $contents); - } - - public function testCanMakeModelWithFactoryUsingForce(): void - { - $this->markTestSkipped('Not implemented yet!'); - - /* @phpstan-ignore-next-line */ - $this->artisan('beyond:make:model User.User --factory'); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_infra_path('User/Factories/UserFactory.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ model }}', $contents); - - $code = $this->artisan('beyond:make:model User.User --factory --force'); - - $code->assertOk(); - } - - public function testCanMakeModelWithMigration(): void - { - $this->artisan('beyond:make:model User.User --migration'); - - $now = new \DateTime(); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_create_users_table.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringContainsString('Schema::create', $contents); - } - - public function testCanMakeModelWithMigrationUsingForce(): void - { - $this->artisan('beyond:make:model User.User --migration'); - - $now = new \DateTime(); - - $file = beyond_domain_path('User/Models/User.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $file = beyond_infra_path('User/Database/Migrations/'.$now->format('Y_m_d_His').'_create_users_table.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringContainsString('Schema::create', $contents); - - $code = $this->artisan('beyond:make:model User.User --migration --force'); - - $code->assertOk(); - } } diff --git a/tests/Commands/MakeNotificationCommandTest.php b/tests/Commands/MakeNotificationCommandTest.php deleted file mode 100644 index 9f2a892..0000000 --- a/tests/Commands/MakeNotificationCommandTest.php +++ /dev/null @@ -1,36 +0,0 @@ -artisan('beyond:make:notification User.UserCreated'); - - $file = beyond_domain_path('User/Notifications/UserCreated.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - } - - public function testCanMakeNotificationUsingForce(): void - { - $this->artisan('beyond:make:notification User.UserCreated'); - - $file = beyond_domain_path('User/Notifications/UserCreated.php'); - $contents = file_get_contents($file); - - $this->assertFileExists($file); - $this->assertStringNotContainsString('{{ namespace }}', $contents); - $this->assertStringNotContainsString('{{ className }}', $contents); - - $code = $this->artisan('beyond:make:notification User.UserCreated'); - - $code->assertOk(); - } -}