textRepo = new FakeTextRepository; $this->textRepo->create(new CreateTextDto( name: 'text' )); $this->nodeRepo = new FakeNodeRepository; $this->useCase = new CreateNode( nodeRepo: $this->nodeRepo, textRepo: $this->textRepo, ); } public function test_create_node(): void { $node = $this->useCase->execute(new CreateNodeRequest( textId: 0, title: 'test', )); $this->assertInstanceOf(NodeRepository::class, $this->nodeRepo); $this->assertInstanceOf(Node::class, $node); $this->assertEquals('test', $node->getTitle()); } public function test_node_belongs_to_text(): void { $node = $this->useCase->execute(new CreateNodeRequest( textId: 0, title: 'test', )); $this->assertInstanceOf(Text::class, $node->getText()); } public function test_throws_if_text_doesnt_exist(): void { $this->expectException(DomainException::class); $node = $this->useCase->execute(new CreateNodeRequest( textId: 1, title: 'test', )); } }