lernschiff/tests/Feature/Tenant/TenantWritePathTest.php

24 lines
640 B
PHP

<?php
use App\Models\License;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use function Pest\Laravel\actingAs;
uses(RefreshDatabase::class);
it('BelongsToTenant überschreibt tenant_id bei non-admin Creation', function () {
$tenant1 = Tenant::factory()->create();
$tenant2 = Tenant::factory()->create();
$user = User::factory()->for($tenant1)->create();
actingAs($user);
$license = License::create([
'type' => 'per_student',
'tenant_id' => $tenant2->id, // attempt cross-tenant write
]);
expect($license->tenant_id)->toBe($tenant1->id);
});