Skip to content
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

[7.x] Add console test method to expect a confirmation question #31965

Merged
merged 2 commits into from
Mar 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Illuminate/Testing/PendingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function __construct(PHPUnitTestCase $test, Container $app, $command, $pa
* Specify a question that should be asked when the command runs.
*
* @param string $question
* @param string $answer
* @param string|bool $answer
* @return $this
*/
public function expectsQuestion($question, $answer)
Expand All @@ -86,6 +86,18 @@ public function expectsQuestion($question, $answer)
return $this;
}

/**
* Specify a confirmation question that should be asked when the command runs.
*
* @param string $question
* @param string $answer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not allowing bool, but the above is?

Copy link
Contributor Author

@ShawnCZek ShawnCZek Mar 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method checks whether the answer is yes/no.
The method above also accepts a bool value as it is the way how to test confirmation questions.

Also, in this method I am passing a bool value to the method above and according to the documentation, it was not possible before. But actually it was.

* @return $this
*/
public function expectsConfirmation($question, $answer = 'no')
{
return $this->expectsQuestion($question, strtolower($answer) === 'yes');
}

/**
* Specify output that should be printed when the command runs.
*
Expand Down