New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.1 - Shell "requested" param #6292
Conversation
I'll fix the failing tests |
@@ -211,7 +211,10 @@ public function initialize() | |||
*/ | |||
public function startup() | |||
{ | |||
$this->_welcome(); | |||
$requested = $this->param('requested'); | |||
if (empty($requested)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just test the truthiness of the param? Given that its always locked to a boolean it will be a yes/no condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
a5cc596
to
2e88862
Compare
@markstory I've refactored it all and went with your suggestion of having a new It might be good to test the parsing of the |
2e88862
to
5db6dc3
Compare
@@ -211,7 +211,9 @@ public function initialize() | |||
*/ | |||
public function startup() | |||
{ | |||
$this->_welcome(); | |||
if (!(bool)$this->param('requested')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!
does implicit boolean casting for you.
Testing |
Ok, that's what I was afraid of. |
@HavokInspiration Another method sounds like a good option to me. |
a4ff279
to
71a9243
Compare
Added a method to parse arguments given to It does feel flying without wings to not have tests validating that Is there no way to test this? With I don't know... A custom test shell that will overwrite class TestingShell extends Shell
{
public $out = [];
public function out($message = null, $newlines = 1, $level = Shell::NORMAL)
{
$this->out[] = $message;
}
public function testTask()
{
$this->out('I am a test task, I dispatch another Shell');
$this->dispatchShell('testing dispatch_test_task');
}
public function dispatchTestTask()
{
$this->out('I am a dispatched Shell');
}
}
//In test files
$TestingShell = new TestingShell();
$TestingShell->runCommand('test_task');
//Compare $TestingShell->out with our own expected array It's a draft done quick and dirty, just to have something more concrete than my so poorly written explanation. But that might give some sort of coverage to |
Looks good to me. |
This "extra" arguments allow additional parameters to be passed to the Shell without them needing to be a CLI flag or a command argument. This commit also introduce a "requested" extra parameter that is automatically passed when a Shell is dispatched with a Shell::dispatchShell() call. This parameter, when set and not null or false, prevents the default cake shell welcome message from being displayed
…Shell::dispatchShell() call. Add tests for that method.
71a9243
to
1cf42b8
Compare
3.1 - Shell "requested" param
@markstory I think this was merged too early. Since master was merged to 3.1, the dispatchShell test added on #6325 will probably fail (the welcome message will not be outputed, hence the expected value will not be correct anymore. I'll try to submit a quick fix for the test for the 3.1 branch with just github online editor (will check on my fork first). |
Whoops. Failing tests can be fixed easily enough 😄 |
Dispatching a Shell within another shell (with
Shell::dispatchShell()
) makes the welcome message called twice :This PR adds a new parameter called "requested" that will prevent the welcome message to be displayed.
By extension, this parameter could be used in userland to detect if the Shell was called with the dispatchMethod.
Additionally, any call to dispatchShell() will append this parameter to the list of parameters.
More details on #6272.