authorRepository = new InMemoryAuthorRepository(); $this->cheepRepository = new InMemoryCheepRepository(); $this->postCheepCommandHandler = new PostCheepCommandHandler($this->authorRepository, $this->cheepRepository); } /** @test */ public function itRaisesExceptionWhenAuthorNotFound(): void { $this->expectException(AuthorDoesNotExist::class); ($this->postCheepCommandHandler)( new PostCheepCommand( Uuid::uuid6()->toString(), 'irrelevant', 'irrelevant' ) ); } /** @test */ public function itShouldAddCheep(): void { $author = AuthorTestDataBuilder::anAuthor()->build(); $this->authorRepository->add($author); $cheepId = Uuid::uuid6(); ($this->postCheepCommandHandler)( new PostCheepCommand( $cheepId->toString(), 'irrelevant', 'irrelevant' ) ); $cheep = $this->cheepRepository->ofId( CheepTestDataBuilder::aCheepIdentity($cheepId) ); $this->assertNotNull($cheep); } }