array(
'title' => 'Test entry',
'in' => '',
'out' => '',
),
1 => array(
'title' => 'Basic HTML entities',
'in' => '"&',
'out' => '"&',
),
2 => array(
'title' => 'HTML entity string',
'in' => '"',
'out' => '"',
),
3 => array(
'title' => 'HTML entity in STRONG tag',
'in' => 'ś', // ś
'out' => 'Ś', // upper ś
),
4 => array(
'title' => 'STRONG tag to upper-case conversion',
'in' => 'ś',
'out' => 'Ś',
),
5 => array(
'title' => 'STRONG inside B tag',
'in' => 'ś',
'out' => 'Ś',
),
6 => array(
'title' => 'Don\'t remove non-printable chars',
'in' => chr(0x002).chr(0x003),
'out' => chr(0x002).chr(0x003),
),
7 => array(
'title' => 'Remove spaces after
',
'in' => 'test
test',
'out' => "test\ntest",
),
8 => array(
'title' => ' handling test',
'in' => '
OUTER BEGINEOF; $ht = new rcube_html2text($html, false, false); $res = $ht->get_text(); $this->assertContains('>> INNER 1', $res, 'Quote inner'); $this->assertContains('>> INNER 3', $res, 'Quote inner'); $this->assertContains('> OUTER END', $res, 'Quote outer'); } function test_broken_blockquotes() { // no end tag $html = <<INNER 1Par 1INNER 2Par 2Par 3INNER 3OUTER END
QUOTED TEXTNO END TAG FOUND EOF; $ht = new rcube_html2text($html, false, false); $res = $ht->get_text(); $this->assertContains('QUOTED TEXT NO END TAG FOUND', $res, 'No quoating on invalid html'); // with some (nested) end tags $html = << QUOTED TEXTINNER 1INNER 2NO END TAG FOUND EOF; $ht = new rcube_html2text($html, false, false); $res = $ht->get_text(); $this->assertContains('QUOTED TEXT INNER 1 INNER 2 NO END', $res, 'No quoating on invalid html'); } function test_links() { $html = 'content'; $expected = 'content [1] Links: ------ [1] http://test.com '; $ht = new rcube_html2text($html, false, true); $res = $ht->get_text(); $this->assertSame($expected, $res, 'Links list'); // href == content (#1490434) $html = 'http://test.com'; $expected = 'http://test.com'; $ht = new rcube_html2text($html, false, true); $res = $ht->get_text(); $this->assertSame($expected, $res, 'Skip link with href == content'); } }