policy = new TenantPolicy(); } public function test_super_admin_can_adjust_credits(): void { $tenant = Tenant::factory()->create(); $user = User::factory()->create([ 'role' => 'super_admin', ]); $this->assertTrue($this->policy->adjustCredits($user, $tenant)); } public function test_tenant_admin_cannot_adjust_credits(): void { $tenant = Tenant::factory()->create(); $user = User::factory()->create([ 'role' => 'tenant_admin', ]); $user->forceFill(['tenant_id' => $tenant->id])->save(); $this->assertFalse($this->policy->adjustCredits($user, $tenant)); } public function test_tenant_admin_can_view_own_tenant(): void { $tenant = Tenant::factory()->create(); $user = User::factory()->create([ 'role' => 'tenant_admin', ]); $user->forceFill(['tenant_id' => $tenant->id])->save(); $this->assertTrue($this->policy->view($user, $tenant)); } public function test_tenant_admin_cannot_view_other_tenant(): void { $tenant = Tenant::factory()->create(); $otherTenant = Tenant::factory()->create(); $user = User::factory()->create([ 'role' => 'tenant_admin', ]); $user->forceFill(['tenant_id' => $tenant->id])->save(); $this->assertFalse($this->policy->view($user, $otherTenant)); } }