createMock(FollowRepository::class); $followRepository->expects($this->once())->method('toAuthorId')->willReturn($emptyFollowersList); $projectionBus = new InMemoryProjectionBus(); $eventHandler = new CheepPostedEventHandler( $followRepository, $projectionBus ); $eventHandler( CheepPosted::create( CheepId::nextIdentity(), AuthorId::nextIdentity(), CheepMessage::write('Hello World!'), new CheepDate( (new DateTimeImmutable( 'now', new \DateTimeZone('UTC') ))->format('Y-m-d H:i:s') ) ) ); $this->assertCount(0, $projectionBus->projections()); } /** * @test * @Given Non Existing Customer Or Without * @When When * @Then */ public function authorWithMultipleFollowers(): void { $rockStarAuthorId = AuthorId::nextIdentity(); $followersList = []; for ($i = 0; $i < 10; $i++) { $followersList[] = Follow::fromAuthorToAuthor( FollowId::nextIdentity(), AuthorId::nextIdentity(), $rockStarAuthorId ); } $followRepository = $this->createMock(FollowRepository::class); $followRepository->expects($this->once())->method('toAuthorId')->willReturn($followersList); $projectionBus = new InMemoryProjectionBus(); $eventHandler = new CheepPostedEventHandler( $followRepository, $projectionBus ); $eventHandler( CheepPosted::create( CheepId::nextIdentity(), $rockStarAuthorId, CheepMessage::write('Hello World!'), new CheepDate( (new DateTimeImmutable( 'now', new \DateTimeZone('UTC') ))->format('Y-m-d H:i:s') ) ) ); $projections = $projectionBus->projections(); $this->assertCount(10, $projections); } }