/**
  * @param array $connection
  * @param null|string $alternativeKey
  * @throws \InvalidArgumentException
  */
 public function addConnection(array $connection, $alternativeKey = null)
 {
     if ($this->findByDbName($connection['dbname'])) {
         throw new \InvalidArgumentException(sprintf('A connection for DB %s already exists', $connection['dbname']));
     }
     if (is_null($alternativeKey)) {
         $alternativeKey = $connection['dbname'];
     }
     Assertion::string($alternativeKey);
     if ($this->connections->containsKey($alternativeKey)) {
         throw new \InvalidArgumentException("A connection for key {$alternativeKey} is already defined");
     }
     $this->connections->add(DbalConnection::fromConfiguration($connection), $alternativeKey);
     $this->saveConnections(true);
 }
 protected function setUp()
 {
     $this->connection = DbalConnection::fromConfiguration(['driver' => 'pdo_sqlite', 'memory' => true, 'dbname' => 'test_db']);
     $testDataTable = new Table("test_data");
     $testDataTable->addColumn("name", "string");
     $testDataTable->addColumn("age", "integer");
     $testDataTable->addColumn("created_at", "datetime");
     $testDataTable->addColumn("price", "float");
     $testDataTable->addColumn("active", "boolean");
     $testDataTable->setPrimaryKey(["name"]);
     $this->connection->connection()->getSchemaManager()->createTable($testDataTable);
     $this->dataTypeLocation = ApplicationDataTypeLocation::fromPath(sys_get_temp_dir());
     $this->commandBus = new CommandBusMock();
     if (!is_dir(sys_get_temp_dir() . "/SqlConnector")) {
         mkdir(sys_get_temp_dir() . "/SqlConnector");
         mkdir(sys_get_temp_dir() . "/SqlConnector/DataType");
     }
     $connections = new DbalConnectionCollection();
     $connections->add($this->connection);
     $this->tableConnectorGenerator = new TableConnectorGenerator($connections, $this->dataTypeLocation, ConfigLocation::fromPath(sys_get_temp_dir()), $this->commandBus, Bootstrap::getServiceManager()->get("config")['prooph.link.sqlconnector']['doctrine_processing_type_map']);
 }