From c342d5c694f1e828c61226f9b0de9d5b96618831 Mon Sep 17 00:00:00 2001 From: Pyae Sone Aung Date: Mon, 2 Jun 2025 11:17:55 +0700 Subject: [PATCH 1/2] feat: make:enum Command --- src/Console/Commands/Make/MakeEnum.php | 10 ++++ .../ModularizedCommandsServiceProvider.php | 2 + tests/Commands/Make/MakeEnumTest.php | 49 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/Console/Commands/Make/MakeEnum.php create mode 100644 tests/Commands/Make/MakeEnumTest.php diff --git a/src/Console/Commands/Make/MakeEnum.php b/src/Console/Commands/Make/MakeEnum.php new file mode 100644 index 0000000..94c9d94 --- /dev/null +++ b/src/Console/Commands/Make/MakeEnum.php @@ -0,0 +1,10 @@ + MakeCast::class, + 'command.enum.make' => MakeEnum::class, 'command.controller.make' => MakeController::class, 'command.console.make' => MakeCommand::class, 'command.channel.make' => MakeChannel::class, diff --git a/tests/Commands/Make/MakeEnumTest.php b/tests/Commands/Make/MakeEnumTest.php new file mode 100644 index 0000000..693bd52 --- /dev/null +++ b/tests/Commands/Make/MakeEnumTest.php @@ -0,0 +1,49 @@ +requiresLaravelVersion('11.0.0'); + + $this->artisan('make:enum', ['--help' => true]) + ->expectsOutputToContain('--module') + ->assertExitCode(0); + } + + public function test_it_scaffolds_a_enum_in_the_module_when_module_option_is_set(): void + { + $command = MakeEnum::class; + $arguments = ['name' => 'Status']; + $expected_path = '/src/Status.php'; + $expected_substrings = [ + 'namespace Modules\TestModule', + 'enum Status', + ]; + + $this->assertModuleCommandResults($command, $arguments, $expected_path, $expected_substrings); + } + + public function test_it_scaffolds_a_enum_in_the_app_when_module_option_is_missing(): void + { + $command = MakeEnum::class; + $arguments = ['name' => 'Status']; + $expected_path = 'app/Status.php'; + $expected_substrings = [ + 'namespace App', + 'enum Status', + ]; + + $this->assertBaseCommandResults($command, $arguments, $expected_path, $expected_substrings); + } +} From 2c8ebaedb86896641875f093d8df93e8cedc11f1 Mon Sep 17 00:00:00 2001 From: Pyae Sone Aung Date: Mon, 2 Jun 2025 11:19:59 +0700 Subject: [PATCH 2/2] fix: style --- src/Support/ModularizedCommandsServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Support/ModularizedCommandsServiceProvider.php b/src/Support/ModularizedCommandsServiceProvider.php index b8abf3d..2688bf2 100644 --- a/src/Support/ModularizedCommandsServiceProvider.php +++ b/src/Support/ModularizedCommandsServiceProvider.php @@ -38,10 +38,10 @@ class ModularizedCommandsServiceProvider extends ServiceProvider { protected array $overrides = [ 'command.cast.make' => MakeCast::class, - 'command.enum.make' => MakeEnum::class, 'command.controller.make' => MakeController::class, 'command.console.make' => MakeCommand::class, 'command.channel.make' => MakeChannel::class, + 'command.enum.make' => MakeEnum::class, 'command.event.make' => MakeEvent::class, 'command.exception.make' => MakeException::class, 'command.factory.make' => MakeFactory::class,