test(phpunit): Fix ConfigTest on Windows

This commit is contained in:
Pierre Rudloff 2019-04-21 19:14:23 +02:00
parent dc4eafe33f
commit 28b99861c2
2 changed files with 15 additions and 10 deletions

View file

@ -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());
}
/**

View file

@ -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');