Merge branch 'MDL-58701-master' of git://github.com/ankitagarwal/moodle

This commit is contained in:
Jake Dallimore 2017-04-27 13:33:10 +08:00
commit ef35154953
2 changed files with 33 additions and 2 deletions

View File

@ -1139,6 +1139,8 @@ class external_settings {
if ((AJAX_SCRIPT == false) && (CLI_SCRIPT == false) && (WS_SERVER == false)) {
// For normal pages, the default should match the default for format_text.
$this->filter = true;
// Use pluginfile.php for web requests.
$this->file = 'pluginfile.php';
}
}
@ -1151,7 +1153,7 @@ class external_settings {
/**
* Return only one instance
*
* @return object
* @return \external_settings
*/
public static function get_instance() {
if (self::$instance === null) {

View File

@ -43,6 +43,36 @@ class core_externallib_testcase extends advanced_testcase {
}
}
/**
* Tests for external_settings class.
*/
public function test_external_settings() {
$settings = \external_settings::get_instance();
$currentraw = $settings->get_raw();
$currentfilter = $settings->get_filter();
$currentfile = $settings->get_file();
$currentfileurl = $settings->get_fileurl();
$this->assertInstanceOf('external_settings', $settings);
// Check apis.
$settings->set_file('plugin.php');
$this->assertEquals('plugin.php', $settings->get_file());
$settings->set_filter(false);
$this->assertFalse($settings->get_filter());
$settings->set_fileurl(false);
$this->assertFalse($settings->get_fileurl());
$settings->set_raw(true);
$this->assertTrue($settings->get_raw());
// Restore original values.
$settings->set_file($currentfile);
$settings->set_filter($currentfilter);
$settings->set_fileurl($currentfileurl);
$settings->set_raw($currentraw);
}
public function test_validate_params() {
$params = array('text'=>'aaa', 'someid'=>'6');
$description = new external_function_parameters(array('someid' => new external_value(PARAM_INT, 'Some int value'),
@ -541,7 +571,6 @@ class core_externallib_testcase extends advanced_testcase {
}
}
}
/*