assertPattern( '/Foo bar<\/span> Foo/', html_hilight($html,'bar') ); } function testHighlightTwoWords() { $html = 'Foo bar Foo php Foo'; $this->assertPattern( '/Foo bar<\/span> Foo php<\/span> Foo/', html_hilight($html,'bar php') ); } function testHighlightTwoWordsHtml() { $html = 'Foo bar Foo php Foo'; $this->assertPattern( '/Foo bar<\/span><\/b> Foo<\/i> php<\/span> Foo/', html_hilight($html,'bar php') ); } function testNoHighlight() { $html = 'Foo bar Foo'; $this->assertPattern( '/Foo bar Foo/', html_hilight($html,'php') ); } function testHighlightPHP() { $html = 'Foo $_GET[\'bar\'] Foo'; $this->assertEqual( 'Foo $_GET[\'bar\'] Foo', html_hilight($html,'$_GET[\'bar\']') ); } function testMatchAttribute() { $html = 'Foo bar Foo'; $this->assertPattern( '/Foo bar<\/b> Foo/', html_hilight($html,'class="x"') ); } function testMatchAttributeWord() { $html = 'Foo bar Foo'; $this->assertEqual( 'Foo bar Foo', html_hilight($html,'class="x">bar') ); } function testRegexInjection() { $html = 'Foo bar Foo'; $this->assertPattern( '/Foo bar Foo/', html_hilight($html,'*') ); } function testRegexInjectionSlash() { $html = 'Foo bar Foo'; $this->assertPattern( '/Foo bar Foo/', html_hilight($html,'x/') ); } }