mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-06 18:34:03 +00:00
Merge branch 'master' into shift-64622
This commit is contained in:
commit
ea0b44522d
42 changed files with 277 additions and 75 deletions
42
tests/DeleteDomainsJobTest.php
Normal file
42
tests/DeleteDomainsJobTest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Tests;
|
||||
|
||||
use Stancl\Tenancy\Database\Concerns\HasDomains;
|
||||
use Stancl\Tenancy\Jobs\DeleteDomains;
|
||||
|
||||
class DeleteDomainsJobTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
config(['tenancy.tenant_model' => DatabaseAndDomainTenant::class]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function job_delete_domains_successfully()
|
||||
{
|
||||
$tenant = DatabaseAndDomainTenant::create();
|
||||
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'foo.localhost',
|
||||
]);
|
||||
$tenant->domains()->create([
|
||||
'domain' => 'bar.localhost',
|
||||
]);
|
||||
|
||||
$this->assertSame($tenant->domains()->count(), 2);
|
||||
|
||||
(new DeleteDomains($tenant))->handle();
|
||||
|
||||
$this->assertSame($tenant->refresh()->domains()->count(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
class DatabaseAndDomainTenant extends Etc\Tenant
|
||||
{
|
||||
use HasDomains;
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ class ExampleSeeder extends Seeder
|
|||
{
|
||||
DB::table('users')->insert([
|
||||
'name' => Str::random(10),
|
||||
'email' => Str::random(10).'@gmail.com',
|
||||
'email' => Str::random(10) . '@gmail.com',
|
||||
'password' => bcrypt('password'),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -559,7 +559,9 @@ class CentralUser extends Model implements SyncMaster
|
|||
use ResourceSyncing, CentralConnection;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public $table = 'users';
|
||||
|
||||
public function tenants(): BelongsToMany
|
||||
|
|
@ -603,7 +605,9 @@ class ResourceUser extends Model implements Syncable
|
|||
use ResourceSyncing;
|
||||
|
||||
protected $table = 'users';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function getGlobalIdentifierKey()
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ class Post extends Model
|
|||
use BelongsToTenant;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function comments()
|
||||
|
|
@ -327,6 +328,7 @@ class Post extends Model
|
|||
class Comment extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
public function post()
|
||||
|
|
@ -350,5 +352,6 @@ class ScopedComment extends Comment
|
|||
class GlobalResource extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public $timestamps = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ class MyTenant extends Tenant
|
|||
class AnotherTenant extends Model implements Contracts\Tenant
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'tenants';
|
||||
|
||||
public function getTenantKeyName(): string
|
||||
|
|
|
|||
|
|
@ -255,11 +255,13 @@ function getRoutes($loginRoute = true, $authGuard = 'web'): Closure
|
|||
class ImpersonationUser extends Authenticable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'users';
|
||||
}
|
||||
|
||||
class AnotherImpersonationUser extends Authenticable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected $table = 'users';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue