<?php dispatch(new App\Jobs\SendEmails);
<?php public function dispatchNextJobInChain()
{
if (! empty($this->chained)) {
dispatch(tap(unserialize(array_shift($this->chained)), function ($next) {
$next->chained = $this->chained;
$next->onConnection($next->connection ?: $this->chainConnection);
$next->onQueue($next->queue ?: $this->chainQueue);
$next->chainConnection = $this->chainConnection;
$next->chainQueue = $this->chainQueue;
$next->chainCatchCallbacks = $this->chainCatchCallbacks;
}));
}
}
<?php public function resolve()
{
return function (...$arguments) {
dispatch(new CallQueuedListener(InvokeQueuedClosure::class, 'handle', [
'closure' => new SerializableClosure($this->closure),
'arguments' => $arguments,
'catch' => collect($this->catchCallbacks)->map(function ($callback) {
return new SerializableClosure($callback);
})->all(),
]))->onConnection($this->connection)->onQueue($this->queue)->delay($this->delay);
};
}
}
<?php protected function dispatch($job)
{
return dispatch($job);
}
<?php public function testItCanHandleTimeoutJob()
{
dispatch(new Fixtures\TimeOutJobWithTransaction);
$this->assertSame(1, DB::table('jobs')->count());
$this->assertSame(0, DB::table('failed_jobs')->count());
<?php public function testJobsCanBeChainedOnSuccessUsingHelper()
{
dispatch(new JobChainingTestFirstJob)->chain([
new JobChainingTestSecondJob,
]);
<?php public function testLockIsReleasedForSuccessfulJobs()
{
UniqueTestJob::$handled = false;
dispatch($job = new UniqueTestJob);
$this->runQueueWorkerCommand(['--once' => true]);
$this->assertTrue($job::$handled);
<?php UniqueTestRetryJob::$handled = false;
dispatch($job = new UniqueTestRetryJob);
$this->assertFalse($this->app->get(Cache::class)->lock($this->getLockKey($job), 10)->get());
<?php $this->markTestSkippedWhenUsingSyncQueueDriver();
UniqueTestReleasedJob::$handled = false;
dispatch($job = new UniqueTestReleasedJob);
$this->assertFalse($this->app->get(Cache::class)->lock($this->getLockKey($job), 10)->get());
<?php UniqueUntilStartTestJob::$handled = false;
dispatch($job = new UniqueUntilStartTestJob);
$this->assertFalse($this->app->get(Cache::class)->lock($this->getLockKey($job), 10)->get());
<?php $job = new TestJob1;
dispatch($job);
dispatch(new TestJob2);
dispatch($job)->onQueue('Q2');
<?php $job = new TestJob1;
dispatch($job);
dispatch(new TestJob2);
dispatch($job)->onQueue('Q2');
$this->assertEquals(2, Queue::size());
<?php dispatch($job);
dispatch(new TestJob2);
dispatch($job)->onQueue('Q2');
$this->assertEquals(2, Queue::size());
$this->assertEquals(1, Queue::size('Q2'));
<?php $parts = array_merge([$command, $package], $extraParams);
dispatch(new RunComposer($this->prepareProcessArguments($parts), $this->getCacheKey($package)));
}