Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Jun 28, 2020
1 parent b55de18 commit 891a29d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
48 changes: 45 additions & 3 deletions src/Illuminate/Foundation/Bus/PendingChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
class PendingChain
{
/**
* The class name of the job being dispatched.
* The name of the connection the chain should be sent to.
*
* @var mixed
* @var string|null
*/
public $job;
public $connection;

/**
* The jobs to be chained.
Expand All @@ -29,6 +29,20 @@ class PendingChain
*/
public $catchCallbacks = [];

/**
* The name of the queue the chain should be sent to.
*
* @var string|null
*/
public $queue;

/**
* The class name of the job being dispatched.
*
* @var mixed
*/
public $job;

/**
* Create a new PendingChain instance.
*
Expand Down Expand Up @@ -65,6 +79,32 @@ public function catchCallbacks()
return $this->catchCallbacks ?? [];
}

/**
* Set the desired connection for the job.
*
* @param string|null $connection
* @return $this
*/
public function onConnection($connection)
{
$this->job->onConnection($connection);

return $this;
}

/**
* Set the desired queue for the job.
*
* @param string|null $queue
* @return $this
*/
public function onQueue($queue)
{
$this->job->onQueue($queue);

return $this;
}

/**
* Dispatch the job with the given arguments.
*
Expand All @@ -81,6 +121,8 @@ public function dispatch()
}

$firstJob->chainCatchCallbacks = $this->catchCallbacks();
$firstJob->allOnQueue($this->queue);
$firstJob->allOnConnection($this->connection);

return (new PendingDispatch($firstJob))->chain($this->chain);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Queue/JobChainingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function testCatchCallbackIsCalledOnFailure()
new JobChainingTestFailingJob(),
new JobChainingTestSecondJob(),
])->catch(function () {
self::$catchCallbackRan = true;
JobChainingTest::$catchCallbackRan = true;
})->dispatch();

$this->assertTrue(JobChainingTestFirstJob::$ran);
Expand Down

0 comments on commit 891a29d

Please sign in to comment.