1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<?php
namespace Illuminate\Tests\Queue;
use Illuminate\Bus\BatchRepository;
use Illuminate\Bus\DatabaseBatchRepository;
use Illuminate\Foundation\Application;
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 Application;
$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 Application;
$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();
}
}
|