'Super Admin', 'guard_name' => 'web']); Permission::firstOrCreate(['name' => 'projects.access', 'guard_name' => 'web']); $this->admin = User::factory()->create([ 'status' => 'active', 'user_type' => 'admin', ]); $this->admin->assignRole($role); $this->project = Project::create([ 'name' => 'Metro Commercial Hub', 'code' => 'PRJ-MCH-2026', 'status' => ProjectStatus::InProgress, 'project_type' => 'standard', 'is_unprofitable' => false, 'contract_value' => 8000000.00, 'current_wizard_step' => 8, ]); $this->report1 = DailyReport::create([ 'project_id' => $this->project->id, 'user_id' => $this->admin->id, 'report_number' => 'DCR-2026-001', 'report_date' => '2026-08-01', 'weather' => 'Sunny', 'remarks' => 'Completed foundation excavation.', ]); $this->report1->labors()->create([ 'trade' => 'Master Carpenter', 'workers_count' => 4, 'hours' => 8, ]); $this->report1->equipment()->create([ 'equipment_name' => 'CAT 320 Excavator', 'hours_used' => 6.5, 'status' => 'Active', ]); $this->report1->materials()->create([ 'material_name' => 'Portland Cement Type 1', 'quantity_received' => '100 bags', 'condition' => 'Good', ]); $this->report1->activities()->create([ 'task_name' => 'Foundation Excavation', 'zone_area' => 'Zone A', 'quantity_completed' => '50 m3', 'percentage_completed' => 40, ]); $this->report1->issues()->create([ 'issue_type' => 'Weather', 'description' => 'Slight heat delay at noon', 'delay_impact' => '30 mins', ]); $this->report2 = DailyReport::create([ 'project_id' => $this->project->id, 'user_id' => $this->admin->id, 'report_number' => 'DCR-2026-002', 'report_date' => '2026-08-02', 'weather' => 'Rainy', 'remarks' => 'Concreting column footings.', ]); $this->report2->labors()->create([ 'trade' => 'Master Carpenter', 'workers_count' => 6, 'hours' => 8, ]); $this->report2->labors()->create([ 'trade' => 'Steel Rebarman', 'workers_count' => 3, 'hours' => 8, ]); $this->report2->equipment()->create([ 'equipment_name' => 'Concrete Transit Mixer 8m3', 'hours_used' => 5.0, 'status' => 'Active', ]); $this->report2->materials()->create([ 'material_name' => 'Portland Cement Type 1', 'quantity_received' => '150 bags', 'condition' => 'Good', ]); $this->report2->activities()->create([ 'task_name' => 'Foundation Excavation', 'zone_area' => 'Zone A', 'quantity_completed' => '80 m3', 'percentage_completed' => 100, ]); } /** @test */ public function test_can_export_daily_reports_date_range_to_excel(): void { $response = $this->actingAs($this->admin)->get(route('projects.daily-reports.export-range', [ 'project' => $this->project->ulid, 'start_date' => '2026-08-01', 'end_date' => '2026-08-05', ])); $response->assertOk(); $this->assertTrue(str_contains($response->headers->get('content-type'), 'spreadsheetml.sheet')); } /** @test */ public function test_can_export_daily_reports_date_range_to_pdf_with_category_summations(): void { $response = $this->actingAs($this->admin)->get(route('projects.daily-reports.pdf-range', [ 'project' => $this->project->ulid, 'start_date' => '2026-08-01', 'end_date' => '2026-08-05', ])); $response->assertOk(); $this->assertTrue(str_contains($response->headers->get('content-type'), 'application/pdf')); } }