Merge branch 'MDL-62394-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Jun Pataleta 2018-05-11 14:23:41 +08:00
commit 0697a52218
2 changed files with 8 additions and 8 deletions

View File

@ -84,7 +84,7 @@ class moodle_content_writer implements content_writer {
public function export_data(array $subcontext, \stdClass $data) : content_writer {
$path = $this->get_path($subcontext, 'data.json');
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE));
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
return $this;
}
@ -115,7 +115,7 @@ class moodle_content_writer implements content_writer {
];
$path = $this->get_path($subcontext, 'metadata.json');
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE));
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
return $this;
}
@ -131,7 +131,7 @@ class moodle_content_writer implements content_writer {
public function export_related_data(array $subcontext, $name, $data) : content_writer {
$path = $this->get_path($subcontext, "{$name}.json");
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE));
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
return $this;
}
@ -230,7 +230,7 @@ class moodle_content_writer implements content_writer {
'value' => $value,
'description' => $description,
];
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE));
$this->write_data($path, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
return $this;
}

View File

@ -897,7 +897,7 @@ class moodle_content_writer_test extends advanced_testcase {
$contextpath = $this->get_context_path($context, $subcontext, 'metadata.json');
$json = $fileroot->getChild($contextpath)->getContent();
$this->assertRegExp("/$text.*$text.*$text/", $json);
$this->assertRegExp("/$text.*$text.*$text/is", $json);
$expanded = json_decode($json);
$this->assertTrue(isset($expanded->$text));
@ -950,7 +950,7 @@ class moodle_content_writer_test extends advanced_testcase {
$contextpath = $this->get_context_path($context, [get_string('userpreferences')], "{$component}.json");
$json = $fileroot->getChild($contextpath)->getContent();
$this->assertRegExp("/$text.*$text.*$text/", $json);
$this->assertRegExp("/$text.*$text.*$text/is", $json);
$expanded = json_decode($json);
$this->assertTrue(isset($expanded->$text));
@ -1053,7 +1053,7 @@ class moodle_content_writer_test extends advanced_testcase {
$this->assertEquals($expectedpath, $contextpath);
$json = $fileroot->getChild($contextpath)->getContent();
$this->assertRegExp("/$text.*$text.*$text/", $json);
$this->assertRegExp("/$text.*$text.*$text/is", $json);
$expanded = json_decode($json);
$this->assertTrue(isset($expanded->$text));
@ -1091,7 +1091,7 @@ class moodle_content_writer_test extends advanced_testcase {
$this->assertEquals($expectedpath, $contextpath);
$json = $fileroot->getChild($contextpath)->getContent();
$this->assertRegExp("/$text.*$text.*$text/", $json);
$this->assertRegExp("/$text.*$text.*$text/is", $json);
$expanded = json_decode($json);
$this->assertTrue(isset($expanded->$text));