/**
  * @test
  */
 public function it_clears_pending_events_after_returning_them()
 {
     $user = User::nameNew('John');
     $recordedEvens = $user->accessRecordedEvents();
     $this->assertEquals(1, count($recordedEvens));
     $recordedEvens = $user->accessRecordedEvents();
     $this->assertEquals(0, count($recordedEvens));
 }
 /**
  * @test
  */
 public function it_translates_aggregate_back_and_forth()
 {
     $this->eventStore->beginTransaction();
     $user = User::nameNew('John Doe');
     $this->repository->addAggregateRoot($user);
     $this->eventStore->commit();
     $this->eventStore->beginTransaction();
     //Simulate a normal program flow by fetching the AR before modifying it
     $user = $this->repository->getAggregateRoot($user->id());
     $user->changeName('Max Mustermann');
     $this->eventStore->commit();
     $this->resetRepository();
     $loadedUser = $this->repository->getAggregateRoot($user->id());
     $this->assertEquals('Max Mustermann', $loadedUser->name());
     return $loadedUser;
 }