1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 17:24:03 +00:00

Queue tests

This commit is contained in:
Samuel Štancl 2020-05-11 05:22:55 +02:00
parent 00bb0d06b3
commit 86a98b2bc8
13 changed files with 216 additions and 124 deletions

View file

@ -23,7 +23,6 @@ class JobPipelineTest extends TestCase
config(['queue.default' => 'redis']);
file_put_contents(__DIR__ . '/../Etc/tmp/jobpipelinetest.json', '{}');
$this->valuestore = Valuestore::make(__DIR__ . '/../Etc/tmp/jobpipelinetest.json')->flush();
}
@ -64,6 +63,22 @@ class JobPipelineTest extends TestCase
});
}
/** @test */
public function job_pipelines_run_when_queued()
{
Event::listen(TenantCreated::class, JobPipeline::make([
FooJob::class,
])->send(function () {
return $this->valuestore;
})->shouldBeQueued(true)->toListener());
$this->assertFalse($this->valuestore->has('foo'));
Tenant::create();
$this->artisan('queue:work --once');
$this->assertSame('bar', $this->valuestore->get('foo'));
}
/** @test */
public function job_pipeline_executes_jobs_and_passes_the_object_sequentially()
{
@ -159,6 +174,7 @@ class JobWithMultipleArguments
public function handle()
{
// we dont queue this job so no need to use valuestore here
app()->instance('test_args', [$this->first, $this->second]);
}
}