From d87cece363399d9b656c140b94684ea8b60e2645 Mon Sep 17 00:00:00 2001 From: Harry Fuecks Date: Tue, 1 Nov 2005 19:49:08 +0100 Subject: html_highlight test cases darcs-hash:20051101184908-56ad0-ea4c38c9a25dcc245c98b1e8cc001cac1427bbb7.gz --- _test/cases/inc/html_hilight.test.php | 98 +++++++++++++++++++++++++++++++++++ _test/debug.note | 4 ++ 2 files changed, 102 insertions(+) create mode 100644 _test/cases/inc/html_hilight.test.php create mode 100644 _test/debug.note (limited to '_test') diff --git a/_test/cases/inc/html_hilight.test.php b/_test/cases/inc/html_hilight.test.php new file mode 100644 index 000000000..304cc71b8 --- /dev/null +++ b/_test/cases/inc/html_hilight.test.php @@ -0,0 +1,98 @@ +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->assertPattern( + '/Foo '.preg_quote('$_GET[\'bar\']').'<\/span> 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->assertPattern( + '/Foo bar<\/b> 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/') + ); + } + +} + diff --git a/_test/debug.note b/_test/debug.note new file mode 100644 index 000000000..28c34d8ee --- /dev/null +++ b/_test/debug.note @@ -0,0 +1,4 @@ +print "-----------------------------------------------------\n"; +print_r(array_map('stripbyteindex',$this->H->calls)); +print "-----------------------------------------------------\n"; +print_r($calls); -- cgit v1.2.3