1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-13 18:24:05 +00:00

tests for shouldQueueOn method

This commit is contained in:
Jonathan Martins 2023-02-25 12:51:34 -03:00
parent 1682f3e8d9
commit c1e27eae4c

View file

@ -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()
{