/**
  * @test
  */
 public function itCommitsAnEventStreamAndThenReadsIt()
 {
     $id = AggregateId::fromString('08cd0c48-6560-430b-93d5-fcb5902f6ae3');
     $originalEventStream = $this->createEventStream($id);
     $this->eventStore->commit($originalEventStream);
     $readEventStream = $this->eventStore->read($id);
     $this->assertEquals($originalEventStream, $readEventStream);
 }
    /**
     * @test
     * @expectedException \SimpleES\EventSourcing\Exception\AggregateIdNotFound
     */
    public function itFailsToReadAnEventStreamWhenTheAggregateIdCannotBeFound()
    {
        $aggregateId = AggregateId::fromString('some-id');
        $sql = <<<EOQ
SELECT event_id, event_name, event_payload, aggregate_version, took_place_at, metadata
FROM event_store
WHERE aggregate_id = :aggregate_id
ORDER BY aggregate_version ASC
EOQ;
        $stmt = Mockery::mock('Doctrine\\DBAL\\Driver\\Statement');
        $stmt->shouldReceive('bindValue')->once()->with('aggregate_id', (string) $aggregateId, Type::GUID);
        $stmt->shouldReceive('execute')->once();
        $stmt->shouldReceive('fetch')->once()->with(PDO::FETCH_ASSOC)->andReturn(false);
        $this->connection->shouldReceive('prepare')->once()->with($sql)->andReturn($stmt);
        $this->eventStore->read($aggregateId);
    }