diff --git a/lib/tests/exporter_test.php b/lib/tests/exporter_test.php index bbcf5b43331..edb1e5ae93f 100644 --- a/lib/tests/exporter_test.php +++ b/lib/tests/exporter_test.php @@ -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); + } } /**