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;
}
];
$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;
}
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;
}
'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;
}
$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));
$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));
$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));
$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));