Changed config.ini hierarchy

This commit is contained in:
Marcin Kurczewski 2014-08-30 18:11:04 +02:00
parent f3096ffc5d
commit ff310f56c5
3 changed files with 15 additions and 10 deletions

View file

@ -1,3 +1,7 @@
databaseHost = localhost
databasePort = 27017;
databaseName = booru-dev
[database]
host = localhost
port = 27017;
name = booru-dev
[security]
secret = change

View file

@ -10,7 +10,7 @@ final class DatabaseConnection
{
$connectionString = $this->getConnectionString($config);
$this->connection = new \MongoClient($connectionString);
$this->database = $this->connection->selectDb($config->databaseName);
$this->database = $this->connection->selectDb($config->database->name);
}
public function getConnection()
@ -27,8 +27,8 @@ final class DatabaseConnection
{
return sprintf(
'mongodb://%s:%d/%s',
$config->databaseHost,
$config->databasePort,
$config->databaseName);
$config->database->host,
$config->database->port,
$config->database->name);
}
}

View file

@ -12,9 +12,10 @@ abstract class AbstractDatabaseTest extends \PHPUnit_Framework_TestCase
$port = 27017;
$database = 'test';
$config = new \Szurubooru\Config();
$config->databaseHost = 'localhost';
$config->databasePort = 27017;
$config->databaseName = 'test';
$config->database = new \StdClass;
$config->database->host = 'localhost';
$config->database->port = 27017;
$config->database->name = 'test';
$this->databaseConnection = new \Szurubooru\DatabaseConnection($config);
$this->upgradeService = new \Szurubooru\UpgradeService($this->databaseConnection);
$this->upgradeService->prepareForUsage();