mirror of
https://github.com/archtechx/tenancy.git
synced 2026-03-22 17:54:03 +00:00
Merge branch '3.x' into 3.x
This commit is contained in:
commit
055f8fdbfe
31 changed files with 189 additions and 172 deletions
|
|
@ -10,6 +10,7 @@ use Illuminate\Events\CallQueuedListener;
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Str;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Stancl\JobPipeline\JobPipeline;
|
||||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Syncable;
|
||||
|
|
@ -71,7 +72,7 @@ class ResourceSyncingTest extends TestCase
|
|||
])->assertExitCode(0);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function an_event_is_triggered_when_a_synced_resource_is_changed()
|
||||
{
|
||||
Event::fake([SyncedResourceSaved::class]);
|
||||
|
|
@ -89,7 +90,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function resources_are_synced_only_sync_is_enabled()
|
||||
{
|
||||
CentralUser::create([
|
||||
|
|
@ -119,7 +120,7 @@ class ResourceSyncingTest extends TestCase
|
|||
$this->assertSame('secret', $centralUser->password); // not sync
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function central_users_are_synced_only_sync_is_enabled()
|
||||
{
|
||||
$centralUser = CentralUser::create([
|
||||
|
|
@ -143,8 +144,8 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
#[Test]
|
||||
public function only_the_synced_columns_are_updated_in_the_central_db()
|
||||
{
|
||||
// Create user in central DB
|
||||
|
|
@ -200,7 +201,7 @@ class ResourceSyncingTest extends TestCase
|
|||
], ResourceUser::first()->getAttributes());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function creating_the_resource_in_tenant_database_creates_it_in_central_database_and_creates_the_mapping()
|
||||
{
|
||||
// Assert no user in central DB
|
||||
|
|
@ -235,7 +236,7 @@ class ResourceSyncingTest extends TestCase
|
|||
$this->assertSame('commenter', ResourceUser::first()->role);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function trying_to_update_synced_resources_from_central_context_using_tenant_models_results_in_an_exception()
|
||||
{
|
||||
$this->creating_the_resource_in_tenant_database_creates_it_in_central_database_and_creates_the_mapping();
|
||||
|
|
@ -247,7 +248,7 @@ class ResourceSyncingTest extends TestCase
|
|||
ResourceUser::first()->update(['role' => 'foobar']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function attaching_a_tenant_to_the_central_resource_triggers_a_pull_from_the_tenant_db()
|
||||
{
|
||||
$centralUser = CentralUser::create([
|
||||
|
|
@ -274,7 +275,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function attaching_users_to_tenants_DOES_NOT_DO_ANYTHING()
|
||||
{
|
||||
$centralUser = CentralUser::create([
|
||||
|
|
@ -303,7 +304,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function resources_are_synced_only_to_workspaces_that_have_the_resource()
|
||||
{
|
||||
$centralUser = CentralUser::create([
|
||||
|
|
@ -347,7 +348,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function when_a_resource_exists_in_other_tenant_dbs_but_is_CREATED_in_a_tenant_db_the_synced_columns_are_updated_in_the_other_dbs()
|
||||
{
|
||||
// create shared resource
|
||||
|
|
@ -394,7 +395,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function the_synced_columns_are_updated_in_other_tenant_dbs_where_the_resource_exists()
|
||||
{
|
||||
// create shared resource
|
||||
|
|
@ -447,7 +448,7 @@ class ResourceSyncingTest extends TestCase
|
|||
$this->assertSame('commenter', $centralUser->role); // unsynced
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function global_id_is_generated_using_id_generator_when_its_not_supplied()
|
||||
{
|
||||
$user = CentralUser::create([
|
||||
|
|
@ -460,7 +461,7 @@ class ResourceSyncingTest extends TestCase
|
|||
$this->assertNotNull($user->global_id);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function when_the_resource_doesnt_exist_in_the_tenant_db_non_synced_columns_will_cascade_too()
|
||||
{
|
||||
$centralUser = CentralUser::create([
|
||||
|
|
@ -483,7 +484,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function when_the_resource_doesnt_exist_in_the_central_db_non_synced_columns_will_bubble_up_too()
|
||||
{
|
||||
$t1 = ResourceTenant::create([
|
||||
|
|
@ -504,7 +505,7 @@ class ResourceSyncingTest extends TestCase
|
|||
$this->assertSame('employee', CentralUser::first()->role);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function the_listener_can_be_queued()
|
||||
{
|
||||
Queue::fake();
|
||||
|
|
@ -532,7 +533,7 @@ class ResourceSyncingTest extends TestCase
|
|||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function an_event_is_fired_for_all_touched_resources()
|
||||
{
|
||||
Event::fake([SyncedResourceChangedInForeignDatabase::class]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue