seedLookupData(); $repository = $this->repository(['project_id' => $fixtures['project']->id]); $ticket = $this->ticket(['project_id' => $fixtures['project']->id]); GitCommit::query()->create([ 'repository_id' => $repository->id, 'ticket_id' => $ticket->id, 'hash' => str_repeat('b', 40), 'short_hash' => 'bbbbbbb', 'branch' => 'develop', 'author_name' => 'Mark Gregory', 'author_email' => 'mark@example.com', 'message' => 'Resolve ' . $ticket->reference . ' ticket save redirect', 'url' => 'https://example.com/commit/b', 'committed_at' => now(), ]); $this->assertDatabaseHas('helpdesk_git_commits', [ 'repository_id' => $repository->id, 'ticket_id' => $ticket->id, 'short_hash' => 'bbbbbbb', ]); self::assertSame($ticket->id, $repository->commits()->firstOrFail()->ticket_id); } public function test_attachment_service_stores_and_deletes_ticket_files(): void { Storage::fake('local'); config()->set('helpdesk.disk', 'local'); $user = $this->user(); $ticket = $this->ticket(['owner' => $user]); $file = UploadedFile::fake()->create('evidence.pdf', 32, 'application/pdf'); app(AttachmentService::class)->storeMany($ticket, [$file], $user->id); $attachment = Attachment::query()->where('ticket_id', $ticket->id)->firstOrFail(); Storage::disk('local')->assertExists($attachment->path); self::assertSame('evidence.pdf', $attachment->original_name); app(AttachmentService::class)->delete($attachment); Storage::disk('local')->assertMissing($attachment->path); $this->assertDatabaseMissing('helpdesk_attachments', ['id' => $attachment->id]); } }