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))); }
public function testSave() { $config = new Config(__DIR__ . '/savetest.config.php'); $this->assertEquals('Test Application', $config->application->name); $config->foo = 'bar'; $config->baz = [1, 2, 3]; $config->songs = ['Hey' => 'Jude', 'I just' => ['call' => ['to' => 'say']]]; $config->save(); $expectedText = <<<'CONFIG' <?php return [ 'application' => [ 'name' => 'Test Application', ], 'foo' => 'bar', 'baz' => [ 0 => 1, 1 => 2, 2 => 3, ], 'songs' => [ 'Hey' => 'Jude', 'I just' => [ 'call' => [ 'to' => 'say', ], ], ], ]; CONFIG; $this->assertEquals(str_replace("\r\n", "\n", $expectedText), str_replace("\r\n", "\n", file_get_contents(__DIR__ . '/savetest.config.php'))); }