-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a simple mechanism to dispatch a new job if the previous job is successful.
- Loading branch information
1 parent
c8a9413
commit 81bcb03
Showing
5 changed files
with
119 additions
and
1 deletion.
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
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
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,55 @@ | ||
<?php | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Orchestra\Testbench\TestCase; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
|
||
/** | ||
* @group integration | ||
*/ | ||
class JobChainingTest extends TestCase | ||
{ | ||
public function tearDown() | ||
{ | ||
JobChainingTestFirstJob::$ran = false; | ||
JobChainingTestSecondJob::$ran = false; | ||
} | ||
|
||
|
||
public function test_jobs_can_be_chained_on_success() | ||
{ | ||
JobChainingTestFirstJob::dispatch()->then([ | ||
new JobChainingTestSecondJob | ||
]); | ||
|
||
$this->assertTrue(JobChainingTestFirstJob::$ran); | ||
$this->assertTrue(JobChainingTestSecondJob::$ran); | ||
} | ||
} | ||
|
||
|
||
class JobChainingTestFirstJob implements ShouldQueue | ||
{ | ||
use Dispatchable, Queueable; | ||
|
||
public static $ran = false; | ||
|
||
public function handle() | ||
{ | ||
static::$ran = true; | ||
} | ||
} | ||
|
||
|
||
class JobChainingTestSecondJob implements ShouldQueue | ||
{ | ||
use Dispatchable, Queueable; | ||
|
||
public static $ran = false; | ||
|
||
public function handle() | ||
{ | ||
static::$ran = true; | ||
} | ||
} |