mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 23:54:03 +00:00
wip
This commit is contained in:
parent
7fe81f37cd
commit
7583f3645d
2 changed files with 62 additions and 1 deletions
|
|
@ -70,7 +70,7 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
{
|
||||
$this->app['queue']->createPayloadUsing(function () {
|
||||
if (tenancy()->initialized) {
|
||||
[$uuid, $domain] = tenant()->get('uuid', 'domain');
|
||||
[$uuid, $domain] = tenant()->get(['uuid', 'domain']);
|
||||
|
||||
return [
|
||||
'tenant_uuid' => $uuid,
|
||||
|
|
|
|||
61
tests/QueueTest.php
Normal file
61
tests/QueueTest.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\Events\JobProcessed;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
||||
class QueueTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
public function queues_use_non_tenant_db_connection()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function tenancy_is_initialized_inside_queues()
|
||||
{
|
||||
// Queue::fake();
|
||||
$this->loadLaravelMigrations(['--database' => 'tenant']);
|
||||
Event::fake();
|
||||
|
||||
dispatch(new TestJob());
|
||||
// Queue::assertPushed(TestJob::class);
|
||||
Event::assertDispatched(JobProcessing::class, function ($event) {
|
||||
return $event->job->payload()['tenant_uuid'] === tenant('uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class TestJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
logger(json_encode(\DB::table('users')->get()));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue