public function __construct($config) { if (empty($config['mongo_data_store'])) { throw new \InvalidArgumentException('Missing mongo_data_store key in config'); } $dataStoreConfiguration = $config['mongo_data_store']; $this->databaseConfiguration = Connection::createFromConfiguration($dataStoreConfiguration); $this->dataStoreWriter = new \MongoClient($this->databaseConfiguration->getConnectionUrl(), $this->databaseConfiguration->getConnectionOptions()); }
public function testConfigurationWithUsernameAndPassword() { $config = array('host' => 'localhost', 'port' => '27017', 'username' => 'username', 'password' => 'password', 'db_name' => 'test-db', 'connect' => true); $dbConfiguration = Connection::createFromConfiguration($config); $this->assertEquals('mongodb://*****:*****@localhost:27017/test-db', $dbConfiguration->getConnectionUrl()); }