repository = new TicketRepository(Database::inMemory()); $this->controller = new TicketController($this->repository); } public function testIndexReturnsAllTickets(): void { $this->repository->create(['title' => 'A']); $response = $this->controller->index(Request::create('GET', '/api/v1/tickets')); self::assertSame(200, $response->status); self::assertCount(1, $response->body()['tickets']); } public function testCreateRejectsMissingTitle(): void { $response = $this->controller->create(Request::create('POST', '/api/v1/tickets', body: [])); self::assertSame(422, $response->status); } public function testCreateReturns201WithTicket(): void { $response = $this->controller->create(Request::create('POST', '/api/v1/tickets', body: ['title' => 'Neu'])); self::assertSame(201, $response->status); self::assertSame('Neu', $response->body()['ticket']['title']); } public function testCreateRejectsInvalidColumnWith422(): void { $response = $this->controller->create(Request::create('POST', '/api/v1/tickets', body: ['title' => 'X', 'column' => 'invalid'])); self::assertSame(422, $response->status); } public function testUpdateMovesTicket(): void { $ticket = $this->repository->create(['title' => 'X']); $response = $this->controller->update( Request::create('PATCH', '/api/v1/tickets/' . $ticket['id'], body: ['column' => 'bereit']), ['id' => (string) $ticket['id']] ); self::assertSame(200, $response->status); self::assertSame('bereit', $response->body()['ticket']['column_name']); } public function testUpdatePropagatesNotFoundForUnknownTicket(): void { $this->expectException(NotFoundException::class); $this->controller->update( Request::create('PATCH', '/api/v1/tickets/999', body: ['column' => 'bereit']), ['id' => '999'] ); } }