| Línea 29... |
Línea 29... |
| 29 |
* @package core_question
|
29 |
* @package core_question
|
| 30 |
* @category test
|
30 |
* @category test
|
| 31 |
* @copyright 2010 The Open University
|
31 |
* @copyright 2010 The Open University
|
| 32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 33 |
*/
|
33 |
*/
|
| 34 |
class questionutils_test extends \advanced_testcase {
|
34 |
final class questionutils_test extends \advanced_testcase {
|
| 35 |
public function test_arrays_have_same_keys_and_values(): void {
|
35 |
public function test_arrays_have_same_keys_and_values(): void {
|
| 36 |
$this->assertTrue(question_utils::arrays_have_same_keys_and_values(
|
36 |
$this->assertTrue(question_utils::arrays_have_same_keys_and_values(
|
| 37 |
array(),
|
37 |
array(),
|
| 38 |
array()));
|
38 |
array()));
|
| 39 |
$this->assertTrue(question_utils::arrays_have_same_keys_and_values(
|
39 |
$this->assertTrue(question_utils::arrays_have_same_keys_and_values(
|
| Línea 224... |
Línea 224... |
| 224 |
$this->assertSame(1.5, question_utils::clean_param_mark('1.5'));
|
224 |
$this->assertSame(1.5, question_utils::clean_param_mark('1.5'));
|
| 225 |
$this->assertSame(1.5, question_utils::clean_param_mark('1,5'));
|
225 |
$this->assertSame(1.5, question_utils::clean_param_mark('1,5'));
|
| 226 |
$this->assertSame(-1.5, question_utils::clean_param_mark('-1.5'));
|
226 |
$this->assertSame(-1.5, question_utils::clean_param_mark('-1.5'));
|
| 227 |
$this->assertSame(-1.5, question_utils::clean_param_mark('-1,5'));
|
227 |
$this->assertSame(-1.5, question_utils::clean_param_mark('-1,5'));
|
| 228 |
}
|
228 |
}
|
| - |
|
229 |
|
| - |
|
230 |
/**
|
| - |
|
231 |
* Test the content is being filtered by filters.
|
| - |
|
232 |
*
|
| - |
|
233 |
* @covers ::format_question_fragment
|
| - |
|
234 |
*/
|
| - |
|
235 |
public function test_format_question_fragment(): void {
|
| - |
|
236 |
global $CFG;
|
| - |
|
237 |
require_once($CFG->libdir . '/filterlib.php');
|
| - |
|
238 |
$this->resetAfterTest();
|
| - |
|
239 |
// Set few filters on.
|
| - |
|
240 |
filter_set_global_state('multilang', TEXTFILTER_ON);
|
| - |
|
241 |
filter_set_global_state('mathjaxloader', TEXTFILTER_ON);
|
| - |
|
242 |
filter_set_applies_to_strings('multilang', 1);
|
| - |
|
243 |
filter_set_applies_to_strings('mathjaxloader', 1);
|
| - |
|
244 |
|
| - |
|
245 |
$systemcontext = \context_system::instance();
|
| - |
|
246 |
$input = 'Some inline math \\( y = x^2 \\) and multi lang with html tag
|
| - |
|
247 |
<span lang="en" class="multilang"><b>English</b></span><span lang="fr" class="multilang">Français</span>';
|
| - |
|
248 |
|
| - |
|
249 |
$expected = question_utils::format_question_fragment($input, $systemcontext);
|
| - |
|
250 |
|
| - |
|
251 |
// The data should only be filtered by mathjax and multi lang filter. HTML tags should not be affeacted.
|
| - |
|
252 |
$this->assertStringContainsString('<span class="filter_mathjaxloader_equation">Some inline math', $expected);
|
| - |
|
253 |
$this->assertStringContainsString('<span class="nolink">\( y = x^2 \)</span>', $expected);
|
| - |
|
254 |
$this->assertStringNotContainsString('<span lang="en" class="multilang">', $expected);
|
| - |
|
255 |
$this->assertStringContainsString('<b>English</b>', $expected);
|
| - |
|
256 |
}
|
| 229 |
}
|
257 |
}
|