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

Fix event listener tests, improve domain logic

This commit is contained in:
Samuel Štancl 2020-05-09 02:49:08 +02:00
parent 0bbc66f451
commit a602cec940
13 changed files with 148 additions and 14 deletions

View file

@ -0,0 +1,32 @@
<?php
namespace Stancl\Tenancy\Tests\v3;
use Stancl\Tenancy\Tests\TestCase;
class AutomaticModeTest extends TestCase
{
/** @test */
public function custom_bootstrappers_can_be_registered()
{
}
/** @test */
public function context_is_switched_when_tenancy_is_initialized()
{
}
/** @test */
public function context_is_reverted_when_tenancy_is_ended()
{
}
/** @test */
public function context_is_switched_when_tenancy_is_reinitialized()
{
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace Stancl\Tenancy\Tests\v3;
use Stancl\Tenancy\Tests\TestCase;
class BootstrapperTest extends TestCase
{
/** @test */
public function database_data_is_separated()
{
}
/** @test */
public function cache_data_is_separated()
{
}
/** @test */
public function redis_data_is_separated()
{
}
/** @test */
public function filesystem_data_is_separated()
{
}
/** @test */
public function queue_data_is_separated()
{
}
}

View file

@ -3,7 +3,7 @@
namespace Stancl\Tenancy\Tests\v3;
use Stancl\Tenancy\Database\Models;
use Stancl\Tenancy\Database\Models\Domain;
use Stancl\Tenancy\Database\Models\Concerns\HasDomains;
use Stancl\Tenancy\Exceptions\DomainsOccupiedByOtherTenantException;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
use Stancl\Tenancy\Resolvers\DomainTenantResolver;
@ -63,8 +63,5 @@ class DomainTest extends TestCase
class Tenant extends Models\Tenant
{
public function domains()
{
return $this->hasMany(Domain::class);
}
use HasDomains;
}

View file

@ -2,6 +2,7 @@
namespace Stancl\Tenancy\Tests\v3;
use Illuminate\Events\CallQueuedListener;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Queue;
use Stancl\Tenancy\Database\Models\Tenant;
@ -9,7 +10,6 @@ use Stancl\Tenancy\Events\Listeners\QueueableListener;
use Stancl\Tenancy\Events\TenantCreated;
use Stancl\Tenancy\Tests\TestCase;
// todo these tests do not pass: https://github.com/laravel/framework/issues/32722
class EventListenerTest extends TestCase
{
/** @test */
@ -30,12 +30,14 @@ class EventListenerTest extends TestCase
{
Queue::fake();
FooListener::$shouldQueue = true;
Event::listen(TenantCreated::class, FooListener::class);
FooListener::$shouldQueue = true;
Tenant::create();
Queue::assertPushed(FooListener::class);
Queue::assertPushed(CallQueuedListener::class, function (CallQueuedListener $job) {
return $job->class === FooListener::class;
});
$this->assertFalse(app()->bound('foo'));
}

View file

@ -106,4 +106,16 @@ class TenantModelTest extends TestCase
$this->assertSame(1, $tenant1->id);
$this->assertSame(2, $tenant2->id);
}
/** @test */
public function custom_tenant_model_can_be_used()
{
}
/** @test */
public function custom_tenant_model_that_doesnt_extend_vendor_Tenant_model_can_be_used()
{
}
}