mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-58701 phpunit: Add tests for external_settings
This commit is contained in:
parent
1d772481dd
commit
9743b2d4a9
@ -1153,7 +1153,7 @@ class external_settings {
|
||||
/**
|
||||
* Return only one instance
|
||||
*
|
||||
* @return object
|
||||
* @return \external_settings
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if (self::$instance === null) {
|
||||
|
@ -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 {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user