Skip to content
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
4 changes: 2 additions & 2 deletions src/Illuminate/Testing/PendingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Traits\Conditionable;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Support\Traits\Tappable;
use Mockery;
use Mockery\Exception\NoMatchingExpectationException;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
Expand All @@ -21,8 +22,7 @@

class PendingCommand
{
use Conditionable;
use Macroable;
use Conditionable, Macroable, Tappable;

/**
* The test being run.
Expand Down
31 changes: 31 additions & 0 deletions tests/Integration/Testing/ArtisanCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ protected function setUp(): void
Artisan::command('contains', function () {
$this->line('My name is Taylor Otwell');
});

Artisan::command('new-england', function () {
$this->line('The region of New England consists of the following states:');
$this->info('Connecticut');
$this->info('Maine');
$this->info('Massachusetts');
$this->info('New Hampshire');
$this->info('Rhode Island');
$this->info('Vermont');
});
}

public function test_console_command_that_passes()
Expand Down Expand Up @@ -275,6 +285,27 @@ public function test_console_command_that_fails_if_the_output_does_not_contain()
});
}

public function test_pending_command_can_be_tapped()
{
$newEngland = [
'Connecticut',
'Maine',
'Massachusetts',
'New Hampshire',
'Rhode Island',
'Vermont',
];

$this->artisan('new-england')
->expectsOutput('The region of New England consists of the following states:')
->tap(function ($command) use ($newEngland) {
foreach ($newEngland as $state) {
$command->expectsOutput($state);
}
})
->assertExitCode(0);
}

/**
* Don't allow Mockery's InvalidCountException to be reported. Mocks setup
* in PendingCommand cause PHPUnit tearDown() to later throw the exception.
Expand Down
Loading