Skip to content

Commit b360ca9

Browse files
committed
Remove support for LOTGD_CONFIG environment variable.
1 parent 9f69823 commit b360ca9

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Some technical notes:
5858
### Configuration
5959
The crate is responsible for configuring the game, which is done through
6060
a configuration file, in the YAML format. The path to the configuration file is
61-
specified by the environment variable `LOTGD_CONFIG`.
61+
`config/lotgd.yml`.
6262

6363
Here's the format of the config file:
6464

config/test.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

phpunit.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<phpunit bootstrap="bootstrap/bootstrap.php">
2-
<php>
3-
<env name="LOTGD_CONFIG" value="./config/test.yml" />
4-
</php>
52
<testsuites>
63
<testsuite name="All">
74
<directory>tests</directory>

src/Bootstrap.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getGame(string $cwd = null): Game
5151
$composer = $this->createComposerManager($cwd);
5252
$this->libraryConfigurationManager = $this->createLibraryConfigurationManager($composer);
5353

54-
$config = $this->createConfiguration();
54+
$config = $this->createConfiguration($cwd);
5555
$logger = $this->createLogger($config, "lotgd");
5656

5757
$pdo = $this->connectToDatabase($config);
@@ -94,16 +94,18 @@ protected function createComposerManager(string $cwd = null): ComposerManager
9494
}
9595

9696
/**
97-
* Returns a configuration object reading from the file located at the path stored in LOTGD_CONFIG.
97+
* Returns a configuration object reading from the file located at the path stored in $cwd/config/lotgd.yml.
9898
* @return \LotGD\Core\Configuration
9999
* @throws InvalidConfigurationException
100100
*/
101-
protected function createConfiguration(): Configuration
101+
protected function createConfiguration(string $cwd = null): Configuration
102102
{
103-
$configFilePath = getenv('LOTGD_CONFIG');
103+
if ($cwd == null) {
104+
$cwd = getcwd();
105+
}
104106

105107
if (empty($configFilePath)) {
106-
$configFilePath = implode(DIRECTORY_SEPARATOR, [getcwd(), "config", "lotgd.yml"]);
108+
$configFilePath = implode(DIRECTORY_SEPARATOR, [$cwd, "config", "lotgd.yml"]);
107109
}
108110

109111
if ($configFilePath === false || strlen($configFilePath) == 0 || is_file($configFilePath) === false) {

tests/GameTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function setUp()
6262
$logger = new Logger('test');
6363
$logger->pushHandler(new NullHandler());
6464

65-
$this->g = new Game(new Configuration(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . getenv('LOTGD_CONFIG')), $logger, $this->getEntityManager());
65+
$this->g = new Game(new Configuration(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'config', 'lotgd.yml'])), $logger, $this->getEntityManager());
6666
}
6767

6868
public function testGetCharacterException()

tests/ModelTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class ModelTestCase extends \PHPUnit_Extensions_Database_TestCase
3131
final public function getConnection(): \PHPUnit_Extensions_Database_DB_DefaultDatabaseConnection
3232
{
3333
if ($this->connection === null) {
34-
$configFilePath = getcwd() . DIRECTORY_SEPARATOR . getenv('LOTGD_CONFIG');
34+
$configFilePath = implode(DIRECTORY_SEPARATOR, [getcwd(), 'config', 'lotgd.yml']);
3535
if ($configFilePath === false || strlen($configFilePath) == 0 || is_file($configFilePath) === false) {
3636
throw new InvalidConfigurationException("Invalid or missing configuration file: '{$configFilePath}'.");
3737
}

0 commit comments

Comments
 (0)