MDL-40759 icons: Update unit tests

Match the expected output for unit tests.
This commit is contained in:
Damyon Wiese 2017-01-31 10:37:02 +08:00
parent 3c8850711f
commit 0b772813dc
4 changed files with 16 additions and 10 deletions

View File

@ -54,8 +54,7 @@ class filter_emoticon_testcase extends advanced_testcase {
$this->assertEquals($expected, $filter->filter('(grr)', $options));
// And texts matching target formats are filtered.
$expected = '<img class="emoticon" alt="angry" title="angry"'.
' src="http://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/angry" />';
$expected = '<i class="icon fa s/angry fa-fw emoticon" aria-hidden="true" title=""></i><span class="sr-only"></span>';
$options = array('originalformat' => FORMAT_HTML); // Only FORMAT_HTML is filtered, see {@link testable_filter_emoticon}.
$this->assertEquals($expected, $filter->filter('(grr)', $options));
}

View File

@ -54,7 +54,8 @@ class core_filter_manager_testcase extends advanced_testcase {
public function test_filter_normal() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertRegExp('~^<p><img class="emoticon" alt="smile" ([^>]+)></p>$~',
$this->assertRegExp('~^<p><i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span></p>$~',
$this->filter_text('<p>:-)</p>', array()));
}
@ -68,7 +69,8 @@ class core_filter_manager_testcase extends advanced_testcase {
public function test_disabling_other_filter_does_not_break_it() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertRegExp('~^<p><img class="emoticon" alt="smile" ([^>]+)></p>$~',
$this->assertRegExp('~^<p><i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span></p>$~',
$this->filter_text('<p>:-)</p>', array('urltolink')));
}
@ -76,7 +78,8 @@ class core_filter_manager_testcase extends advanced_testcase {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
filter_set_global_state('urltolink', TEXTFILTER_ON);
$this->assertRegExp('~^<p><img class="emoticon" alt="smile" ([^>]+)> http://google.com/</p>$~',
$this->assertRegExp('~^<p><i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span> http://google.com/</p>$~',
$this->filter_text('<p>:-) http://google.com/</p>', array('glossary', 'urltolink')));
}
}

View File

@ -37,7 +37,8 @@ class core_weblib_format_text_testcase extends advanced_testcase {
public function test_format_text_format_html() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertRegExp('~^<p><img class="emoticon" alt="smile" ([^>]+)></p>$~',
$this->assertRegExp('~^<p><i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span></p>$~',
format_text('<p>:-)</p>', FORMAT_HTML));
}
@ -66,7 +67,8 @@ class core_weblib_format_text_testcase extends advanced_testcase {
public function test_format_text_format_markdown() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertRegExp('~^<p><em><img class="emoticon" alt="smile" ([^>]+)></em></p>\n$~',
$this->assertRegExp('~^<p><em><i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span></em></p>\n$~',
format_text('*:-)*', FORMAT_MARKDOWN));
}
@ -80,7 +82,9 @@ class core_weblib_format_text_testcase extends advanced_testcase {
public function test_format_text_format_moodle() {
$this->resetAfterTest();
filter_set_global_state('emoticon', TEXTFILTER_ON);
$this->assertRegExp('~^<div class="text_to_html"><p><img class="emoticon" alt="smile" ([^>]+)></p></div>$~',
$this->assertRegExp('~^<div class="text_to_html"><p>' .
'<i class="icon fa s/smiley fa-fw emoticon" aria-hidden="true" title=""></i>' .
'<span class="sr-only"></span></p></div>$~',
format_text('<p>:-)</p>', FORMAT_MOODLE));
}

View File

@ -143,12 +143,12 @@ class mod_resource_lib_testcase extends advanced_testcase {
$info = resource_get_coursemodule_info(
$DB->get_record('course_modules', array('id' => $resource2->cmid)));
$this->assertEquals('R2', $info->name);
$this->assertEquals('f/text-24', $info->icon);
$this->assertEquals('f/text', $info->icon);
// For third one, it should use the highest sortorder icon.
$info = resource_get_coursemodule_info(
$DB->get_record('course_modules', array('id' => $resource3->cmid)));
$this->assertEquals('R3', $info->name);
$this->assertEquals('f/document-24', $info->icon);
$this->assertEquals('f/document', $info->icon);
}
}