forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10.x] Allow pruning all cancelled and unfinished queue batches (lara…
…vel#46833) * Allow pruning all cancelled and unfinished batches * Apply fixes from StyleCI
- Loading branch information
1 parent
5e0b756
commit fb96849
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Queue; | ||
|
||
use Illuminate\Bus\BatchRepository; | ||
use Illuminate\Bus\DatabaseBatchRepository; | ||
use Illuminate\Container\Container; | ||
use Illuminate\Queue\Console\PruneBatchesCommand; | ||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
|
||
class PruneBatchesCommandTest extends TestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
m::close(); | ||
} | ||
|
||
public function testAllowPruningAllUnfinishedBatches() | ||
{ | ||
$container = new Container; | ||
$container->instance(BatchRepository::class, $repo = m::spy(DatabaseBatchRepository::class)); | ||
|
||
$command = new PruneBatchesCommand; | ||
$command->setLaravel($container); | ||
|
||
$command->run(new ArrayInput(['--unfinished' => 0]), new NullOutput()); | ||
|
||
$repo->shouldHaveReceived('pruneUnfinished')->once(); | ||
} | ||
|
||
public function testAllowPruningAllCancelledBatches() | ||
{ | ||
$container = new Container; | ||
$container->instance(BatchRepository::class, $repo = m::spy(DatabaseBatchRepository::class)); | ||
|
||
$command = new PruneBatchesCommand; | ||
$command->setLaravel($container); | ||
|
||
$command->run(new ArrayInput(['--cancelled' => 0]), new NullOutput()); | ||
|
||
$repo->shouldHaveReceived('pruneCancelled')->once(); | ||
} | ||
} |