taxonomyService = $this->createMock(TaxonomyServiceInterface::class); $this->reader = new TaxonomyServiceReader($this->taxonomyService); } public function testFindAllMapsCategoriesToTaxonViews(): void { $this->taxonomyService->expects($this->once()) ->method('findAll') ->willReturn([ new Taxon(1, 'PHP', 'php'), new Taxon(2, 'Slim', 'slim'), ]); $taxons = $this->reader->findAll(); self::assertCount(2, $taxons); self::assertSame('PHP', $taxons[0]->name); self::assertSame('slim', $taxons[1]->slug); } public function testFindBySlugReturnsNullWhenMissing(): void { $this->taxonomyService->expects($this->once()) ->method('findBySlug') ->with('missing') ->willReturn(null); self::assertNull($this->reader->findBySlug('missing')); } }