See moodle.org, google, univ-lemans and google. Also try google via HTTPS.'; $result = html_to_text($text, 5000, true); $this->assertSame(0, strpos($result, 'See moodle.org [1], google [2], univ-lemans [3] and google [2]. Also try google via HTTPS [4].')); $this->assertSame(false, strpos($result, '[0]')); $this->assertSame(1, preg_match('|^'.preg_quote('[1] http://moodle.org').'$|m', $result)); $this->assertSame(1, preg_match('|^'.preg_quote('[2] http://www.google.fr').'$|m', $result)); $this->assertSame(1, preg_match('|^'.preg_quote('[3] http://www.univ-lemans.fr').'$|m', $result)); $this->assertSame(1, preg_match('|^'.preg_quote('[4] https://www.google.fr').'$|m', $result)); $this->assertSame(false, strpos($result, '[5]')); } /** * Various invalid HTML typed by users that ignore html strict. **/ public function test_invalid_html() { $text = 'Gin & Tonic'; $result = html_to_text($text, null, false, false); $this->assertSame($result, $text); $text = 'Gin > Tonic'; $result = html_to_text($text, null, false, false); $this->assertSame($result, $text); $text = 'Gin < Tonic'; $result = html_to_text($text, null, false, false); $this->assertSame($result, $text); } /** * Basic text formatting. */ public function test_simple() { $this->assertSame("_Hello_ WORLD!\n", html_to_text('
Hello world!
All the world’s a stage.
-- William Shakespeare
void FillMeUp(char* in_string) {'. ' int i = 0; while (in_string[i] != \'\0\') { in_string[i] = \'X\'; i++; }'. '}
section are Unicode NBSPs - they may not be displayed in your editor. $strconv = 'Consider the following function: void FillMeUp(char* in_string) { int i = 0; while (in_string[i] != \'\0\') { in_string[i] = \'X\'; i++; } } What would happen if a non-terminated string were input to this function? '; $this->assertSame($strconv, html_to_text($strorig)); } /** * Scripts should be stripped. */ public function test_strip_scripts() { $this->assertSame('Interesting text', html_to_text('Interesting text', 0)); } }