1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-12 20:04:03 +00:00

simplify tests

This commit is contained in:
Samuel Štancl 2023-03-16 22:11:00 +01:00 committed by GitHub
parent 6804be3243
commit 1a75385d9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,17 +81,24 @@ class JobPipelineTest extends TestCase
} }
/** @test */ /** @test */
public function job_pipelines_run_when_pushed_to_another_queue() public function job_pipelines_can_use_a_specific_queue()
{ {
Event::listen(TestEvent::class, JobPipeline::make([ Event::listen(TestEvent::class, JobPipeline::make([
FooJob::class, FooJob::class,
])->send(function () { ])->send(function () {
return $this->valuestore; return $this->valuestore;
})->shouldBeQueued(true, 'another') })->shouldBeQueued(queue: 'another')->toListener());
->toListener());
$this->assertFalse($this->valuestore->has('foo')); $this->assertFalse($this->valuestore->has('foo'));
event(new TestEvent(new TestModel())); event(new TestEvent(new TestModel()));
$this->artisan('queue:work --once --queue=default');
sleep(1);
// Job hasn't run since it was pushed to the 'another' queue
$this->assertNull($this->valuestore->get('foo'));
$this->artisan('queue:work --once --queue=another'); $this->artisan('queue:work --once --queue=another');
sleep(1); sleep(1);
@ -99,25 +106,6 @@ class JobPipelineTest extends TestCase
$this->assertSame('bar', $this->valuestore->get('foo')); $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;
})->shouldBeQueued(true, '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 */ /** @test */
public function job_pipeline_executes_jobs_and_passes_the_object_sequentially() public function job_pipeline_executes_jobs_and_passes_the_object_sequentially()
{ {