setRepo = new FakeSetRepository(); $this->elementRepo = new FakeElementRepository(); $this->createSet = new CreateSet( $this->setRepo, $this->elementRepo, ); } public function testCreatesSet(): void { $set = $this->createSet->execute( new CreateSetRequest('Daily learning') ); $this->assertInstanceOf(DomainSet::class, $set); $this->assertSame(1, $set->getId()); $this->assertSame('Daily learning', $set->getName()); } public function testCreatesRootElementForSet(): void { $set = $this->createSet->execute( new CreateSetRequest('Daily learning') ); $elements = $this->elementRepo->findBySet($set); $this->assertCount(1, $elements); $this->assertSame('Daily learning', $elements[0]->getTitle()); $this->assertSame($set->getId(), $elements[0]->getSet()->getId()); $this->assertNull($elements[0]->getParentElement()); } public function testThrowsWhenNameMissing(): void { $this->expectException(BadRequestException::class); $this->expectExceptionMessage('name is required'); $this->createSet->execute(new CreateSetRequest(null)); } }