string $html, 1 => string $text) $cases = []; $cases[] = [ '

', '', ]; $cases[] = [ "\n

\n" . "This is a paragraph with Bold and italics\n" . "Also some hrefs and a\n" . "few mailto tags.\n" . "This is also a really long long line\n" . "\n", "This is a paragraph with BOLD and _italics_ Also some hrefs [1] and a few\n" . "mailto tags. This is also a really long long line\n" . "\n" . "Links:\n" . "------\n" . "[1] http://www.example.com\n" . "", ]; $cases[] = [ "

\nA token\nis not treated as a relative URL", "A token [1] is not treated as a relative URL\n" . "\n" . "Links:\n" . "------\n" . "[1] {action.do_something}\n", ]; return $cases; } /** * @param string $html * Example HTML input. * @param string $text * Expected text output. * @dataProvider htmlToTextExamples */ public function testHtmlToText($html, $text) { $output = CRM_Utils_String::htmlToText($html); $this->assertEquals( trim($output), trim($text), "Text Output did not match for $html" ); } }