diff --git a/src/Commands/ActionMakeCommand.php b/src/Commands/ActionMakeCommand.php index c023cc9..0ad3db5 100644 --- a/src/Commands/ActionMakeCommand.php +++ b/src/Commands/ActionMakeCommand.php @@ -6,5 +6,6 @@ class ActionMakeCommand extends ActionCommand { protected $signature = 'make:ussd-action {name : The name of the USSD Action} + {--init : Create the class as the initial USSD action} {--force : Create the class even if USSD action already exists}'; } diff --git a/src/Commands/ExceptionHandlerCommand.php b/src/Commands/ExceptionHandlerCommand.php new file mode 100644 index 0000000..887f492 --- /dev/null +++ b/src/Commands/ExceptionHandlerCommand.php @@ -0,0 +1,24 @@ +extendNamespace('ExceptionHandlers'); + } +} diff --git a/src/Commands/ExceptionHandlerMakeCommand.php b/src/Commands/ExceptionHandlerMakeCommand.php new file mode 100644 index 0000000..2ed041f --- /dev/null +++ b/src/Commands/ExceptionHandlerMakeCommand.php @@ -0,0 +1,10 @@ +getMessage(); + } +} diff --git a/tests/Integration/CommandTest.php b/tests/Integration/CommandTest.php index d534379..b0734d4 100644 --- a/tests/Integration/CommandTest.php +++ b/tests/Integration/CommandTest.php @@ -7,7 +7,8 @@ final class CommandTest extends TestCase { - public function test_action_command_print_out_success_when_class_does_not_exists() + /** @dataProvider data_available_make_commands */ + public function test_action_command_print_out_success_when_class_does_not_exists($command, $class) { File::shouldReceive('exists')->once(); File::shouldReceive('isDirectory')->once(); @@ -15,59 +16,34 @@ public function test_action_command_print_out_success_when_class_does_not_exists File::shouldReceive('get')->once(); File::shouldReceive('put')->once(); - $this->artisan('ussd:action', ['name' => 'Save']) - ->expectsOutputToContain('USSD Action [app/Ussd/Actions/Save.php] created successfully.') + $this->artisan($command, ['name' => $class]) + ->expectsOutputToContain($class) ->assertExitCode(0); } - public function test_action_command_print_out_error_when_class_exists() + /** @dataProvider data_available_make_commands */ + public function test_action_command_print_out_error_when_class_exists($command, $class) { File::shouldReceive('exists')->once()->andReturn(true); - $this->artisan('ussd:action', ['name' => 'Save']) - ->expectsOutputToContain('USSD Action already exists.') + $this->artisan($command, ['name' => $class]) + ->expectsOutputToContain('already exists.') ->assertExitCode(0); } - /** @dataProvider data_available_make_commands */ - public function test_make_commands_are_available($command) - { - $this->artisan($command, ['name' => 'NameLess'])->assertExitCode(0); - } - public static function data_available_make_commands() { return [ - ['ussd:state'], - ['make:ussd-state'], - ['ussd:action'], - ['make:ussd-action'], - ['ussd:decision'], - ['make:ussd-decision'], - ['ussd:configurator'], - ['make:ussd-configurator'], + ['ussd:state', 'WelcomeState'], + ['make:ussd-state', 'WelcomeState'], + ['ussd:action', 'MenuAction'], + ['make:ussd-action', 'MenuAction'], + ['ussd:decision', 'StrictEqual'], + ['make:ussd-decision', 'StrictEqual'], + ['ussd:configurator', 'DynamicConfigurator'], + ['make:ussd-configurator', 'DynamicConfigurator'], + ['ussd:exception-handler', 'CatchExceptionHandler'], + ['make:ussd-exception-handler', 'CatchExceptionHandler'], ]; } - - public function test_state_command_print_out_success_when_class_does_not_exists() - { - File::shouldReceive('exists')->once(); - File::shouldReceive('isDirectory')->once(); - File::shouldReceive('makeDirectory')->once(); - File::shouldReceive('get')->once(); - File::shouldReceive('put')->once(); - - $this->artisan('ussd:state', ['name' => 'Welcome']) - ->expectsOutputToContain('USSD State [app/Ussd/States/Welcome.php] created successfully.') - ->assertExitCode(0); - } - - public function test_state_command_print_out_error_when_class_exists() - { - File::shouldReceive('exists')->once()->andReturn(true); - - $this->artisan('ussd:state', ['name' => 'Welcome']) - ->expectsOutputToContain('USSD State already exists.') - ->assertExitCode(0); - } }