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

[9.x] Fixes confirm component default value #43334

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/Illuminate/Console/ConfirmableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function confirmToProceed($warning = 'Application In Production', $callba
$confirmed = $this->components->confirm('Do you really wish to run this command?');

if (! $confirmed) {
$this->newLine();

$this->components->warn('Command canceled.');

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/View/Components/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Confirm extends Component
* @param bool $default
* @return bool
*/
public function render($question, $default = true)
public function render($question, $default = false)
{
return $this->usingQuestionHelper(
fn () => $this->output->confirm($question, $default),
Expand Down
10 changes: 9 additions & 1 deletion tests/Console/View/ComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ public function testConfirm()
$output = m::mock(OutputStyle::class);

$output->shouldReceive('confirm')
->with('Question?', true)
->with('Question?', false)
->once()
->andReturnTrue();

$result = with(new Components\Confirm($output))->render('Question?');
$this->assertTrue($result);

$output->shouldReceive('confirm')
->with('Question?', true)
->once()
->andReturnTrue();

$result = with(new Components\Confirm($output))->render('Question?', true);
$this->assertTrue($result);
}

public function testChoice()
Expand Down