Skip to content

Commit

Permalink
Updated \SlimMvcTools\Functions\CliHelpers\createController to return…
Browse files Browse the repository at this point in the history
… \SlimMvcTools\Functions\CliHelpers\CliExitCodes::SUCCESS_EXIT when the controller class or index view to be created already exist.
  • Loading branch information
rotimi committed May 31, 2024
1 parent 38f637e commit bb3f808
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/scripts/cli-script-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ function createController($argc, array $argv): CreateControllerReturnValue {
if( file_exists($dest_controller_class_file) ) {

return new CreateControllerReturnValue(
CliExitCodes::FAILURE_EXIT,
CliExitCodes::SUCCESS_EXIT,
"Controller class `$studly_controller_name` already exists in `$dest_controller_class_file`. Goodbye!!"
);
}

if( file_exists($dest_view_file) ) {

return new CreateControllerReturnValue(
CliExitCodes::FAILURE_EXIT,
CliExitCodes::SUCCESS_EXIT,
"View file `$dest_view_file` already exists for Controller class `$studly_controller_name`. Goodbye!!"
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/CliScriptHelperFunctionsNamespacedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function testThatCreateControllerWorksAsExpectedWhenDestinationController

$expected_message = "Controller class `ChildController` already exists in `{$dest_controller_class_file}`. Goodbye!!";

self::assertEquals(\SlimMvcTools\Functions\CliHelpers\CliExitCodes::FAILURE_EXIT, $return_val->getReturnCode());
self::assertEquals(\SlimMvcTools\Functions\CliHelpers\CliExitCodes::SUCCESS_EXIT, $return_val->getReturnCode());
self::assertEquals($expected_message, $return_val->getReturnMessage());
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ public function testThatCreateControllerWorksAsExpectedWhenDestinationViewIndexD

$expected_message = "View file `$dest_view_file` already exists for Controller class `ControllerWithNoControllerClass`. Goodbye!!";

self::assertEquals(\SlimMvcTools\Functions\CliHelpers\CliExitCodes::FAILURE_EXIT, $return_val->getReturnCode());
self::assertEquals(\SlimMvcTools\Functions\CliHelpers\CliExitCodes::SUCCESS_EXIT, $return_val->getReturnCode());
self::assertEquals($expected_message, $return_val->getReturnMessage());
}
}
Expand Down

0 comments on commit bb3f808

Please sign in to comment.