mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-52263 libraries: Add test cases to external_format_text options
This commit is contained in:
parent
19a131edff
commit
b1a9804a9b
@ -836,7 +836,7 @@ function external_format_text($text, $textformat, $contextid, $component, $filea
|
||||
// If context is passed in options, check that is the same to show a debug message.
|
||||
if (isset($options['context'])) {
|
||||
if ((is_object($options['context']) && $options['context']->id != $contextid)
|
||||
|| $options['context'] != $contextid) {
|
||||
|| (!is_object($options['context']) && $options['context'] != $contextid)) {
|
||||
debugging('Different contexts found in external_format_text parameters. $options[\'context\'] not allowed.
|
||||
Using $contextid parameter...', DEBUG_DEVELOPER);
|
||||
}
|
||||
|
@ -96,6 +96,40 @@ class core_externallib_testcase extends advanced_testcase {
|
||||
</span></span>', FORMAT_HTML);
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0), $correct);
|
||||
|
||||
$test = '<p><a id="test"></a><a href="#test">Text</a></p>';
|
||||
$testformat = FORMAT_HTML;
|
||||
$correct = array($test, FORMAT_HTML);
|
||||
$options = array('allowid' => true);
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0, $options), $correct);
|
||||
|
||||
$test = '<p><a id="test"></a><a href="#test">Text</a></p>';
|
||||
$testformat = FORMAT_HTML;
|
||||
$correct = array('<p><a></a><a href="#test">Text</a></p>', FORMAT_HTML);
|
||||
$options = new StdClass();
|
||||
$options->allowid = false;
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0, $options), $correct);
|
||||
|
||||
$test = '<p><a id="test"></a><a href="#test">Text</a></p>'."\n".'Newline';
|
||||
$testformat = FORMAT_MOODLE;
|
||||
$correct = array('<p><a id="test"></a><a href="#test">Text</a></p> Newline', FORMAT_HTML);
|
||||
$options = new StdClass();
|
||||
$options->newlines = false;
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0, $options), $correct);
|
||||
|
||||
$test = '<p><a id="test"></a><a href="#test">Text</a></p>';
|
||||
$testformat = FORMAT_MOODLE;
|
||||
$correct = array('<div class="text_to_html">'.$test.'</div>', FORMAT_HTML);
|
||||
$options = new StdClass();
|
||||
$options->para = true;
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0, $options), $correct);
|
||||
|
||||
$test = '<p><a id="test"></a><a href="#test">Text</a></p>';
|
||||
$testformat = FORMAT_MOODLE;
|
||||
$correct = array($test, FORMAT_HTML);
|
||||
$options = new StdClass();
|
||||
$options->context = $context;
|
||||
$this->assertSame(external_format_text($test, $testformat, $context->id, 'core', '', 0, $options), $correct);
|
||||
|
||||
$settings->set_raw($currentraw);
|
||||
$settings->set_filter($currentfilter);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user