guardian()->create(); $student = User::factory()->create(); $guardian->students()->attach($student->id); $response = $this->getJson("/api/v1/guardian/students/{$student->id}/summary", [ 'Authorization' => 'Bearer '.$guardian->api_token, ]); $response->assertOk() ->assertJsonPath('student.id', $student->id) ->assertJsonStructure([ 'student' => ['id', 'name'], 'lessons_progress', 'weakest_concepts', 'latest_ai_summary', ]); } #[Test] public function guardian_cannot_view_unlinked_student(): void { $guardian = User::factory()->guardian()->create(); $otherStudent = User::factory()->create(); $this->getJson("/api/v1/guardian/students/{$otherStudent->id}/summary", [ 'Authorization' => 'Bearer '.$guardian->api_token, ])->assertForbidden(); } }