Logger and Configuration have test suites

This commit is contained in:
Guillermo Dev
2018-10-12 16:14:40 +02:00
parent eb4ba2935c
commit c59b044ba7
4 changed files with 189 additions and 34 deletions

View File

@@ -16,12 +16,14 @@ class ConfigurationTest extends TestCase
);
protected $defaultConfig;
protected $dummyConfigFilePath;
protected $dummyConfigFilePath1;
protected $dummyConfigFilePath2;
public function setUp()
{
$this->defaultConfig = array('session' => array('save_path' => session_save_path()));
$this->dummyConfigFilePath = realpath(dirname(__FILE__) . '/../../../config/configuration.local.php');
$this->dummyConfigFilePath1 = realpath(dirname(__FILE__) . '/../../../config/configuration.local.php');
$this->dummyConfigFilePath2 = realpath(dirname(__FILE__) . '/../../../config/configuration.logger.quiet.php');
}
public function testConfigurationInstanceIsTheSame()
@@ -118,14 +120,20 @@ class ConfigurationTest extends TestCase
public function testDummyConfigFileExists()
{
$this->assertEquals(file_exists($this->dummyConfigFilePath), true);
$this->assertEquals(file_exists($this->dummyConfigFilePath1), true);
}
public function testFileCustomConfigGetsLoadedIfFileExists()
{
$configPriorToFileLoading = Configuration::get();
Configuration::setConfigFilePath($this->dummyConfigFilePath);
Configuration::getInstance()->loadConfigFromFile();
$this->assertSame(Configuration::get(), array_replace_recursive($this->testConfig, include $this->dummyConfigFilePath));
Configuration::setConfigFilePath($this->dummyConfigFilePath1);
$this->assertSame(Configuration::get(), array_replace_recursive($this->testConfig, include $this->dummyConfigFilePath1));
}
public function testSetConfigFilePathWithSecondParamTrueClearsPreviousConfig()
{
$configPriorToFileLoading = Configuration::get();
Configuration::setConfigFilePath($this->dummyConfigFilePath2, true);
$this->assertSame(Configuration::get(), include $this->dummyConfigFilePath2);
}
}