Skip to content
Permalink
Browse files

Make JsonConfig pretty print config files.

This makes JSON config files slightly less horrible to work with as you
can read them now.

Refs #8338
  • Loading branch information...
markstory committed Feb 24, 2016
1 parent 262ec6e commit 05f26e1d9508bf2eef80a7224d33168523e29351
@@ -93,6 +93,6 @@ public function read($key)
public function dump($key, array $data)
{
$filename = $this->_getFilePath($key);
return file_put_contents($filename, json_encode($data)) > 0;
return file_put_contents($filename, json_encode($data, JSON_PRETTY_PRINT)) > 0;
}
}
@@ -157,7 +157,20 @@ public function testDump()
$engine = new JsonConfig(TMP);
$result = $engine->dump('test', $this->testData);
$this->assertTrue($result > 0);
$expected = '{"One":{"two":"value","three":{"four":"value four"},"is_null":null,"bool_false":false,"bool_true":true},"Asset":{"timestamp":"force"}}';
$expected = '{
"One": {
"two": "value",
"three": {
"four": "value four"
},
"is_null": null,
"bool_false": false,
"bool_true": true
},
"Asset": {
"timestamp": "force"
}
}';
$file = TMP . 'test.json';
$contents = file_get_contents($file);

0 comments on commit 05f26e1

Please sign in to comment.
You can’t perform that action at this time.