public function testValidConfig() { $config = new Config(); $config->load(__DIR__ . DS . 'config.test.php'); $this->assertInstanceOf('T4\\Core\\Std', $config->db); $this->assertInstanceOf('T4\\Core\\Std', $config); $this->assertEquals('mysql', $config->db->default->driver); $this->assertEquals('localhost', $config->db->default->host); $this->assertEquals('test', $config->name); }
public function testSave() { $config = new Config(); $config->load(self::TEST_CONFIG_FILE); $config->db->default = 42; $config->save(); $expected = <<<FILE <?php return [ 'db' => [ 'default' => 42, ], 'name' => 'test', ]; FILE; $expected = str_replace(["\r\n", "\r", "\n"], '', $expected); $this->assertEquals($expected, str_replace(["\r\n", "\r", "\n"], '', file_get_contents(self::TEST_CONFIG_FILE))); }