<?php namespace Tests\Feature; use Tests\TestCase; use Illuminate\Foundation\Testing\RefreshDatabase; use App\Models\{User,Role,Intern,Office,Shift}; class PortalSeparationTest extends TestCase { use RefreshDatabase; public function test_intern_cannot_open_employee_portal():void{$ir=Role::create(['name'=>'Intern','slug'=>'intern']);$u=User::create(['name'=>'Intern','email'=>'i@example.com','password'=>'secret']);$u->email_verified_at=now();$u->save();$u->roles()->attach($ir);$o=Office::create(['name'=>'HQ','code'=>'HQ','timezone'=>'Asia/Karachi']);$s=Shift::create(['name'=>'General','start_time'=>'09:00','end_time'=>'18:00']);Intern::create(['user_id'=>$u->id,'intern_code'=>'I1','office_id'=>$o->id,'shift_id'=>$s->id,'start_date'=>today(),'status'=>'active']);$this->actingAs($u)->get('/employee')->assertForbidden();$this->actingAs($u)->get('/intern')->assertOk();} }