app->register(ServiceProvider::class); } public function test_it_downloads_the_sales_report_as_a_pdf(): void { $response = app(AdminAppSalePdfService::class)->downloadSales( $this->tenant(), collect([$this->sale()]), ); $this->assertSame('application/pdf', $response->headers->get('content-type')); $this->assertStringContainsString( 'attachment; filename=ventas_acme_', (string) $response->headers->get('content-disposition'), ); $this->assertStringStartsWith('%PDF', $response->getContent()); } public function test_it_downloads_the_modification_history_as_a_pdf(): void { $sale = $this->sale(); $admin = (new User)->forceFill([ 'id' => 10, 'nombre_apellido' => 'Admin Test', 'email' => 'admin@example.test', ]); $modification = (new ValueChange)->forceFill([ 'id' => 1, 'trackable_id' => $sale->id, 'attribute' => 'status', 'old_value' => Purchase::STATUS_PENDING_PAYMENT, 'new_value' => Purchase::STATUS_PAID, 'changed_at' => now(), 'actor_type' => 'user', ]); $modification->setRelation('trackable', $sale); $modification->setRelation('user', $admin); $response = app(AdminAppSalePdfService::class)->downloadModifications( $this->tenant(), collect([$modification]), ); $this->assertSame('application/pdf', $response->headers->get('content-type')); $this->assertStringContainsString( 'attachment; filename=historial_modificaciones_acme_', (string) $response->headers->get('content-disposition'), ); $this->assertStringStartsWith('%PDF', $response->getContent()); } private function tenant(): Tenant { return (new Tenant)->forceFill([ 'codigo' => 'acme', 'nombre' => 'Acme Eventos', ]); } private function sale(): Purchase { return (new Purchase)->forceFill([ 'id' => 15, 'created_at' => now(), 'nombre_apellido' => 'Cliente Test', 'quantity' => 2, 'status' => Purchase::STATUS_PAID, 'total' => '25000.00', 'tickets_count' => 2, ]); } }