mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-52335 mod_lti: php7 compatibility in variable syntax
This commit is contained in:
parent
f9ba07133a
commit
ccfd168a6d
@ -868,7 +868,7 @@ function lti_parse_custom_parameter($toolproxy, $tool, $params, $value, $islti2)
|
||||
$value = $params[$val];
|
||||
} else {
|
||||
$valarr = explode('->', substr($val, 1), 2);
|
||||
$value = "{${$valarr[0]}->$valarr[1]}";
|
||||
$value = "{${$valarr[0]}->{$valarr[1]}}";
|
||||
$value = str_replace('<br />' , ' ', $value);
|
||||
$value = str_replace('<br>' , ' ', $value);
|
||||
$value = format_string($value);
|
||||
|
@ -63,8 +63,11 @@ require_once($CFG->dirroot . '/mod/lti/servicelib.php');
|
||||
class mod_lti_locallib_testcase extends advanced_testcase {
|
||||
|
||||
public function test_split_custom_parameters() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$tool = new stdClass();
|
||||
$tool->enabledcapability = '';
|
||||
$tool->parameter = '';
|
||||
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(), "x=1\ny=2", false),
|
||||
array('custom_x' => '1', 'custom_y' => '2'));
|
||||
|
||||
@ -76,6 +79,12 @@ class mod_lti_locallib_testcase extends advanced_testcase {
|
||||
$this->assertEquals(lti_split_custom_parameters(null, $tool, array(),
|
||||
'Complex!@#$^*(){}[]KEY=Complex!@#$^*;(){}[]½Value', false),
|
||||
array('custom_complex____________key' => 'Complex!@#$^*;(){}[]½Value'));
|
||||
|
||||
// Test custom parameter that returns $USER property.
|
||||
$user = $this->getDataGenerator()->create_user(array('middlename' => 'SOMETHING'));
|
||||
$this->setUser($user);
|
||||
$this->assertEquals(array('custom_x' => '1', 'custom_y' => 'SOMETHING'),
|
||||
lti_split_custom_parameters(null, $tool, array(), "x=1\ny=\$Person.name.middle", false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user