/**
  * @test
  */
 public function it_allows_store_and_find_events_in_mysql_using_jms_serializer_database()
 {
     $connection = $this->getMysqlConnection();
     $schemaManager = new SchemaManager($connection);
     $schemaManager->dropStreamTable(new EventStream\Name(static::class));
     $schemaManager->createStreamTable(new EventStream\Name(static::class));
     $id = new MyAggreagateRootId(Uuid::uuid4());
     $otherId = new MyAggreagateRootId(Uuid::uuid4());
     $events = [new MyFakeEvent($id, ['myPreciousInformation' => '1', 'test' => 'otherTest']), new MyFakeEvent($id, ['myPreciousInformation' => '2', 'test' => 'otherTest']), new MyFakeEvent($otherId, ['myPreciousInformation' => '1', 'test' => 'what?'])];
     $eventSerializer = new JMSEventSerializer(SerializerBuilder::create()->addMetadataDir(__DIR__ . '/jms/mapping', 'Tests\\Cocoders\\Dbal\\EventStore')->build());
     $eventStore = new EventStore($connection, $eventSerializer);
     $eventStore->apply(new EventStream\Name(static::class), $events);
     $unncommitedEvents = $eventStore->findUncommited(new EventStream\Name(static::class))->all();
     $this->assertCount(3, $unncommitedEvents, 'Has all uncommited events before commit');
     $eventStore->commit();
     $unncommitedEvents = $eventStore->findUncommited(new EventStream\Name(static::class))->all();
     $this->assertCount(0, $unncommitedEvents, 'After commit uncommitedEvents are removed');
     $eventStore = new EventStore($connection, $eventSerializer);
     $allEvents = $eventStore->all(new EventStream\Name(static::class))->all();
     $this->assertCount(3, $allEvents, 'Found all events from given stream');
     $aggregateEvents = $eventStore->find(new EventStream\Name(static::class), $id)->all();
     $this->assertCount(2, $aggregateEvents, 'Found all aggregate events from stream');
     $this->assertInstanceOf(MyFakeEvent::class, $aggregateEvents[0], 'Found event is valid type/class');
     $this->assertEquals(['myPreciousInformation' => '1', 'test' => 'otherTest'], $aggregateEvents[0]->getData(), 'Found event has valid data');
 }
 private function insertEvent(EventStream\Name $streamName, Event $event)
 {
     $this->connection->insert(SchemaManager::normalizeToTableName($streamName), ['aggregate_id' => (string) $event->getAggreagateRootId(), 'name' => $event->getName(), 'occurred_on' => $event->occurredOn(), 'event' => $this->serializer->serialize($event), 'event_class' => get_class($event)], [\PDO::PARAM_STR, \PDO::PARAM_STR, 'datetime', 'text', \PDO::PARAM_STR]);
 }