Skip to content

Commit

Permalink
Fixes confirm default value (#43334)
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro authored Jul 21, 2022
1 parent 3877ff9 commit a324e92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
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

0 comments on commit a324e92

Please sign in to comment.