diff --git a/tests/JobPipelineTest.php b/tests/JobPipelineTest.php index 6331770..27cf520 100644 --- a/tests/JobPipelineTest.php +++ b/tests/JobPipelineTest.php @@ -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() {