MDL-76723 core_external: Test invalid required value for format fields

This commit is contained in:
Frédéric Massart
2023-12-19 15:50:21 +08:00
committed by Jun Pataleta
parent 1bd5dfe090
commit def6645cdc
+20
View File
@@ -202,6 +202,26 @@ class exporter_test extends \advanced_testcase {
// Assert nested elements are formatted correctly.
$this->assertEquals('id', $properties['nestedarray']['type']['id']['description']);
}
public function test_format_properties_with_optional() {
$testable = new class([]) extends \core\external\exporter {
public static function define_properties() {
return [
'content' => [
'type' => PARAM_RAW,
'optional' => true,
],
'contentformat' => [
'type' => PARAM_INT,
'optional' => true,
]
];
}
};
$definition = $testable::get_read_structure();
$this->assertEquals(VALUE_OPTIONAL, $definition->keys['content']->required);
$this->assertEquals(VALUE_OPTIONAL, $definition->keys['contentformat']->required);
}
}
/**