test(phpunit): Fix ConfigTest on Windows
This commit is contained in:
parent
dc4eafe33f
commit
28b99861c2
2 changed files with 15 additions and 10 deletions
|
@ -14,9 +14,11 @@ use PHPUnit\Framework\TestCase;
|
||||||
abstract class BaseTest extends 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') {
|
if (PHP_OS == 'WINNT') {
|
||||||
$configFile = 'config_test_windows.yml';
|
$configFile = 'config_test_windows.yml';
|
||||||
|
@ -24,7 +26,15 @@ abstract class BaseTest extends TestCase
|
||||||
$configFile = 'config_test.yml';
|
$configFile = 'config_test.yml';
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::setFile(__DIR__.'/../config/'.$configFile);
|
return __DIR__.'/../config/'.$configFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare tests.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
Config::setFile($this->getConfigFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,13 +67,7 @@ class ConfigTest extends BaseTest
|
||||||
*/
|
*/
|
||||||
public function testSetFile()
|
public function testSetFile()
|
||||||
{
|
{
|
||||||
if (PHP_OS == 'WINNT') {
|
$this->assertNull(Config::setFile($this->getConfigFile()));
|
||||||
$configFile = 'config_test_windows.yml';
|
|
||||||
} else {
|
|
||||||
$configFile = 'config_test.yml';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertNull(Config::setFile(__DIR__.'/../config/'.$configFile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,6 +136,7 @@ class ConfigTest extends BaseTest
|
||||||
{
|
{
|
||||||
Config::destroyInstance();
|
Config::destroyInstance();
|
||||||
putenv('CONVERT=1');
|
putenv('CONVERT=1');
|
||||||
|
Config::setFile($this->getConfigFile());
|
||||||
$config = Config::getInstance();
|
$config = Config::getInstance();
|
||||||
$this->assertEquals($config->convert, true);
|
$this->assertEquals($config->convert, true);
|
||||||
putenv('CONVERT');
|
putenv('CONVERT');
|
||||||
|
|
Loading…
Reference in a new issue