test(user): add parent-side cascade test, remove unused import
parent
2fb1700075
commit
331f6b2077
|
|
@ -3,8 +3,6 @@
|
||||||
use App\Models\License;
|
use App\Models\License;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use function Pest\Laravel\actingAs;
|
|
||||||
|
|
||||||
uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);
|
uses(\Illuminate\Foundation\Testing\RefreshDatabase::class);
|
||||||
|
|
||||||
it('soft-delete User bereinigt role_user, parent_child, license_assignments', function () {
|
it('soft-delete User bereinigt role_user, parent_child, license_assignments', function () {
|
||||||
|
|
@ -25,6 +23,18 @@ it('soft-delete User bereinigt role_user, parent_child, license_assignments', fu
|
||||||
expect(\DB::table('users')->where('id', $userId)->whereNotNull('deleted_at')->count())->toBe(1);
|
expect(\DB::table('users')->where('id', $userId)->whereNotNull('deleted_at')->count())->toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('soft-delete Parent bereinigt parent_child.parent_id', function () {
|
||||||
|
$parent = User::factory()->withRole('parent')->create();
|
||||||
|
$child = User::factory()->withRole('child')->create();
|
||||||
|
$parent->children()->attach($child->id);
|
||||||
|
|
||||||
|
$parentId = $parent->id;
|
||||||
|
$parent->delete();
|
||||||
|
|
||||||
|
expect(\DB::table('parent_child')->where('parent_id', $parentId)->count())->toBe(0);
|
||||||
|
expect(\DB::table('users')->where('id', $parentId)->whereNotNull('deleted_at')->count())->toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('cross-tenant parent-child attach möglich (Option B)', function () {
|
it('cross-tenant parent-child attach möglich (Option B)', function () {
|
||||||
$tenant1 = Tenant::factory()->create();
|
$tenant1 = Tenant::factory()->create();
|
||||||
$tenant2 = Tenant::factory()->create();
|
$tenant2 = Tenant::factory()->create();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue