mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:04:02 +00:00
Test that DeleteResourceMapping works with forceDelete()
This commit is contained in:
parent
b6e52035e7
commit
daa1b907b0
1 changed files with 22 additions and 0 deletions
|
|
@ -966,6 +966,28 @@ test('pivot record is automatically deleted with the tenant resource', function(
|
||||||
|
|
||||||
// Deleting tenant resource deletes its pivot record
|
// Deleting tenant resource deletes its pivot record
|
||||||
expect(DB::select("SELECT * FROM tenant_users WHERE tenant_id = ?", [$tenant->id]))->toHaveCount(0);
|
expect(DB::select("SELECT * FROM tenant_users WHERE tenant_id = ?", [$tenant->id]))->toHaveCount(0);
|
||||||
|
|
||||||
|
// The same works with forceDelete
|
||||||
|
addExtraColumns(true);
|
||||||
|
|
||||||
|
$syncMaster = CentralUserWithSoftDeletes::create([
|
||||||
|
'global_id' => 'force_cascade_user',
|
||||||
|
'name' => 'Central user',
|
||||||
|
'email' => 'central2@localhost',
|
||||||
|
'password' => 'password',
|
||||||
|
'role' => 'force_cascade_user',
|
||||||
|
'foo' => 'bar',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$syncMaster->tenants()->attach($tenant);
|
||||||
|
|
||||||
|
expect(DB::select("SELECT * FROM tenant_users WHERE tenant_id = ?", [$tenant->id]))->toHaveCount(1);
|
||||||
|
|
||||||
|
$tenant->run(function () {
|
||||||
|
TenantUserWithSoftDeletes::firstWhere('global_id', 'force_cascade_user')->forceDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(DB::select("SELECT * FROM tenant_users WHERE tenant_id = ?", [$tenant->id]))->toHaveCount(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('DeleteAllTenantMappings handles incorrect configuration correctly', function() {
|
test('DeleteAllTenantMappings handles incorrect configuration correctly', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue