mirror of
https://github.com/archtechx/jobpipeline.git
synced 2025-12-13 21:24:03 +00:00
tests for shouldQueueOn method
This commit is contained in:
parent
1682f3e8d9
commit
c1e27eae4c
1 changed files with 39 additions and 1 deletions
|
|
@ -80,6 +80,44 @@ class JobPipelineTest extends TestCase
|
|||
$this->assertSame('bar', $this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function job_pipelines_run_when_pushed_to_another_queue()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
FooJob::class,
|
||||
])->send(function () {
|
||||
return $this->valuestore;
|
||||
})->shouldBeQueuedOn('another')
|
||||
->toListener());
|
||||
|
||||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
event(new TestEvent(new TestModel()));
|
||||
$this->artisan('queue:work --once --queue=another');
|
||||
|
||||
sleep(1);
|
||||
|
||||
$this->assertSame('bar', $this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function job_pipelines_that_have_been_pushed_to_another_queue_will_not_run_in_the_default_queue()
|
||||
{
|
||||
Event::listen(TestEvent::class, JobPipeline::make([
|
||||
FooJob::class,
|
||||
])->send(function () {
|
||||
return $this->valuestore;
|
||||
})->shouldBeQueuedOn('another')
|
||||
->toListener());
|
||||
|
||||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
event(new TestEvent(new TestModel()));
|
||||
$this->artisan('queue:work --once --queue=default');
|
||||
|
||||
sleep(1);
|
||||
|
||||
$this->assertNull($this->valuestore->get('foo'));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function job_pipeline_executes_jobs_and_passes_the_object_sequentially()
|
||||
{
|
||||
|
|
@ -133,7 +171,7 @@ class JobPipelineTest extends TestCase
|
|||
// Foo job is not excuted
|
||||
$this->assertFalse($this->valuestore->has('foo'));
|
||||
}
|
||||
|
||||
|
||||
/** @test */
|
||||
public function the_pipeline_can_execute_failed_method_on_job()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue