MDL-75788 testing: Handle new lines in menu profile field generator
This commit is contained in:
@@ -1320,6 +1320,11 @@ EOD;
|
||||
[$data['categoryid']]) + 1;
|
||||
}
|
||||
|
||||
if ($data['datatype'] === 'menu' && isset($data['param1'])) {
|
||||
// Convert new lines to the proper character.
|
||||
$data['param1'] = str_replace('\n', "\n", $data['param1']);
|
||||
}
|
||||
|
||||
// Defaults for other values.
|
||||
$defaults = [
|
||||
'description' => '',
|
||||
|
||||
@@ -577,5 +577,12 @@ class testing_generator_test extends \advanced_testcase {
|
||||
$field7 = $generator->create_custom_profile_field(
|
||||
['datatype' => 'checkbox', 'shortname' => 'areyousure', 'name' => 'Are you sure?']);
|
||||
$this->assertEquals(0, $field7->defaultdata);
|
||||
|
||||
// Check setting options for menu using \n work as expected.
|
||||
$field8 = $generator->create_custom_profile_field([
|
||||
'datatype' => 'menu', 'shortname' => 'cuisine', 'name' => 'Cuisine', 'param1' => 'French\nChinese\nLebanese',
|
||||
'defaultdata' => 'Chinese'
|
||||
]);
|
||||
$this->assertEquals("French\nChinese\nLebanese", $field8->param1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user