diff --git a/tests/BaseTest.php b/tests/BaseTest.php index ab76316..d3f7796 100644 --- a/tests/BaseTest.php +++ b/tests/BaseTest.php @@ -14,9 +14,11 @@ use PHPUnit\Framework\TestCase; abstract class BaseTest extends TestCase { /** - * Prepare tests. + * Get the config file used in tests. + * + * @return string Path to file */ - protected function setUp() + protected function getConfigFile() { if (PHP_OS == 'WINNT') { $configFile = 'config_test_windows.yml'; @@ -24,7 +26,15 @@ abstract class BaseTest extends TestCase $configFile = 'config_test.yml'; } - Config::setFile(__DIR__.'/../config/'.$configFile); + return __DIR__.'/../config/'.$configFile; + } + + /** + * Prepare tests. + */ + protected function setUp() + { + Config::setFile($this->getConfigFile()); } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 5cf850c..13cf4c6 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -67,13 +67,7 @@ class ConfigTest extends BaseTest */ public function testSetFile() { - if (PHP_OS == 'WINNT') { - $configFile = 'config_test_windows.yml'; - } else { - $configFile = 'config_test.yml'; - } - - $this->assertNull(Config::setFile(__DIR__.'/../config/'.$configFile)); + $this->assertNull(Config::setFile($this->getConfigFile())); } /** @@ -142,6 +136,7 @@ class ConfigTest extends BaseTest { Config::destroyInstance(); putenv('CONVERT=1'); + Config::setFile($this->getConfigFile()); $config = Config::getInstance(); $this->assertEquals($config->convert, true); putenv('CONVERT');