elementRepo = new FakeElementRepository(); $getElement = new GetElement($this->elementRepo); $this->controller = new ElementController($getElement); } public function testShowReturnsElementPayload(): void { $element = $this->createElement('Baderech HaAvodah'); $response = $this->controller->show($element->getId()); $this->assertEquals(200, $response->getStatusCode()); $body = json_decode($response->getContent(), true); $this->assertSame($element->getId(), $body['element']['id']); $this->assertSame('Baderech HaAvodah', $body['element']['title']); } public function testShowReturns400WhenIdMissing(): void { $response = $this->controller->show(null); $this->assertEquals(400, $response->getStatusCode()); $this->assertSame( ['error' => 'id is required'], json_decode($response->getContent(), true), ); } public function testShowReturns404WhenElementDoesNotExist(): void { $response = $this->controller->show(999); $this->assertEquals(404, $response->getStatusCode()); $this->assertSame( ['error' => 'Element not found'], json_decode($response->getContent(), true), ); } private function createElement(string $title): Element { $set = new DomainSet( id: 1, name: 'Baderech', description: 'Baderech description', iconImageUrl: '/assets/baderech-icon.png', ); return $this->elementRepo->create(new CreateElementDto( set: $set, title: $title, parentElement: null, )); } }