Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
b1a9804a
Commit
b1a9804a
authored
Apr 12, 2016
by
Pau Ferrer
Browse files
MDL-52263 libraries: Add test cases to external_format_text options
parent
19a131ed
Changes
2
Show whitespace changes
Inline
Side-by-side
lib/externallib.php
View file @
b1a9804a
...
...
@@ -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
);
}
...
...
lib/tests/externallib_test.php
View file @
b1a9804a
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment