fileManager = new ConfigFileManager; /*copy defaultTestConfig file to cache*/ if (!file_exists($this->configPath)) { copy($this->defaultTestConfig, $this->configPath); } $this->config = new Config($this->fileManager); $this->reflection = new ReflectionHelper($this->config); $this->reflection->setProperty('configPath', $this->configPath); $this->reflection->setProperty('systemConfigPath', $this->systemConfigPath); } protected function tearDown() : void { $this->config = NULL; } public function testLoadConfig() { $this->assertArrayHasKey('database', $this->reflection->invokeMethod('loadConfig', array())); $this->assertArrayHasKey('dateFormat', $this->reflection->invokeMethod('loadConfig', array())); } public function testGet() { $result = array( 'driver' => 'pdo_mysql', 'host' => 'localhost', 'dbname' => 'espocrm', 'user' => 'root', 'password' => '', ); $this->assertEquals($result, $this->config->get('database')); $result = 'pdo_mysql'; $this->assertEquals($result, $this->config->get('database.driver')); $result = 'YYYY-MM-DD'; $this->assertEquals($result, $this->config->get('dateFormat')); $this->assertTrue($this->config->get('isInstalled')); } public function testSystemConfigMerge() { $configDataWithoutSystem = $this->fileManager->getPhpContents($this->configPath); $this->assertArrayNotHasKey('systemItems', $configDataWithoutSystem); $this->assertArrayNotHasKey('adminItems', $configDataWithoutSystem); $configData = $this->reflection->invokeMethod('loadConfig', array()); $this->assertArrayHasKey('systemItems', $configData); $this->assertArrayHasKey('adminItems', $configData); } }