summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2007-03-26 20:55:33 +0200
committerAndreas Gohr <andi@splitbrain.org>2007-03-26 20:55:33 +0200
commitebdfc0385552c37d59889f8b9b13f7777d852500 (patch)
tree36fd681638dd063a306de4b8d2668ffc5cb7f2d7 /_test
parentf77429b85e175fe6d9cdba3f30b2fd19662b21e6 (diff)
downloadrpg-ebdfc0385552c37d59889f8b9b13f7777d852500.tar.gz
rpg-ebdfc0385552c37d59889f8b9b13f7777d852500.tar.bz2
some test cleanups
darcs-hash:20070326185533-7ad00-487a00e955386bdccd145928c7d69178327ded69.gz
Diffstat (limited to '_test')
-rw-r--r--_test/cases/inc/html_hilight.test.php210
-rw-r--r--_test/cases/inc/parser/xhtml_links.test.php2
2 files changed, 107 insertions, 105 deletions
diff --git a/_test/cases/inc/html_hilight.test.php b/_test/cases/inc/html_hilight.test.php
index 944c90f1e..634ef2585 100644
--- a/_test/cases/inc/html_hilight.test.php
+++ b/_test/cases/inc/html_hilight.test.php
@@ -1,104 +1,106 @@
-<?php
-
-require_once DOKU_INC.'inc/html.php';
-
-if ( !extension_loaded('runkit') ) {
- SimpleTestOptions::ignore('html_hilight_test');
- trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required');
-}
-
-function html_hilight_test_unslash($string,$char="'"){
- $str= str_replace('\\'.$char,$char,$string);
- return $str;
-}
-
-class html_hilight_test extends UnitTestCase{
-
- function setup() {
- if ( function_exists('unslash') ) {
- runkit_function_rename('unslash','html_hilight_test_unslash_real');
- }
- runkit_function_rename('html_hilight_test_unslash','unslash');
- }
-
- function teardown() {
- runkit_function_rename('unslash','html_hilight_test_unslash');
- if ( function_exists('html_hilight_test_unslash_real') ) {
- runkit_function_rename('html_hilight_test_unslash_real','unslash');
- }
- }
-
- function testHighlightOneWord() {
- $html = 'Foo bar Foo';
- $this->assertPattern(
- '/Foo <span.*>bar<\/span> Foo/',
- html_hilight($html,'bar')
- );
- }
-
- function testHighlightTwoWords() {
- $html = 'Foo bar Foo php Foo';
- $this->assertPattern(
- '/Foo <span.*>bar<\/span> Foo <span.*>php<\/span> Foo/',
- html_hilight($html,'bar php')
- );
- }
-
- function testHighlightTwoWordsHtml() {
- $html = 'Foo <b>bar</b> <i>Foo</i> php Foo';
- $this->assertPattern(
- '/Foo <b><span.*>bar<\/span><\/b> <i>Foo<\/i> <span.*>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 <span class="search_hit">$_GET</span>[\'<span class="search_hit">bar</span>\'] Foo',
- html_hilight($html,'$_GET[\'bar\']')
- );
- }
-
- function testMatchAttribute() {
- $html = 'Foo <b class="x">bar</b> Foo';
- $this->assertPattern(
- '/Foo <b class="x">bar<\/b> Foo/',
- html_hilight($html,'class="x"')
- );
- }
-
- function testMatchAttributeWord() {
- $html = 'Foo <b class="x">bar</b> Foo';
- $this->assertEqual(
- 'Foo <b class="x"><span class="search_hit">bar</span></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/')
- );
- }
-
-}
-
+<?php
+
+require_once DOKU_INC.'inc/html.php';
+
+if ( !extension_loaded('runkit') &&
+ !@dl('runkit.dll') &&
+ !@dl('runkit.so' ) ){
+ SimpleTestOptions::ignore('html_hilight_test');
+ trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required');
+}
+
+function html_hilight_test_unslash($string,$char="'"){
+ $str= str_replace('\\'.$char,$char,$string);
+ return $str;
+}
+
+class html_hilight_test extends UnitTestCase{
+
+ function setup() {
+ if ( function_exists('unslash') ) {
+ runkit_function_rename('unslash','html_hilight_test_unslash_real');
+ }
+ runkit_function_rename('html_hilight_test_unslash','unslash');
+ }
+
+ function teardown() {
+ runkit_function_rename('unslash','html_hilight_test_unslash');
+ if ( function_exists('html_hilight_test_unslash_real') ) {
+ runkit_function_rename('html_hilight_test_unslash_real','unslash');
+ }
+ }
+
+ function testHighlightOneWord() {
+ $html = 'Foo bar Foo';
+ $this->assertPattern(
+ '/Foo <span.*>bar<\/span> Foo/',
+ html_hilight($html,'bar')
+ );
+ }
+
+ function testHighlightTwoWords() {
+ $html = 'Foo bar Foo php Foo';
+ $this->assertPattern(
+ '/Foo <span.*>bar<\/span> Foo <span.*>php<\/span> Foo/',
+ html_hilight($html,'bar php')
+ );
+ }
+
+ function testHighlightTwoWordsHtml() {
+ $html = 'Foo <b>bar</b> <i>Foo</i> php Foo';
+ $this->assertPattern(
+ '/Foo <b><span.*>bar<\/span><\/b> <i>Foo<\/i> <span.*>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 <span class="search_hit">$_GET</span>[\'<span class="search_hit">bar</span>\'] Foo',
+ html_hilight($html,'$_GET[\'bar\']')
+ );
+ }
+
+ function testMatchAttribute() {
+ $html = 'Foo <b class="x">bar</b> Foo';
+ $this->assertPattern(
+ '/Foo <b class="x">bar<\/b> Foo/',
+ html_hilight($html,'class="x"')
+ );
+ }
+
+ function testMatchAttributeWord() {
+ $html = 'Foo <b class="x">bar</b> Foo';
+ $this->assertEqual(
+ 'Foo <b class="x"><span class="search_hit">bar</span></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/cases/inc/parser/xhtml_links.test.php b/_test/cases/inc/parser/xhtml_links.test.php
index 42ffb020e..6a74445b0 100644
--- a/_test/cases/inc/parser/xhtml_links.test.php
+++ b/_test/cases/inc/parser/xhtml_links.test.php
@@ -12,7 +12,7 @@ class xhtml_links_test extends UnitTestCase {
$p = new Doku_Renderer_xhtml();
$p->emaillink('foo@example.com','<script>alert(\'"alert"\');</script>');
- $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="mail JSnocheck" title="foo [at] example [dot] com">&lt;script&gt;alert(\'&quot;alert&quot;\');&lt;/script&gt;</a>';
+ $expect = '<a href="mailto:foo%20%5Bat%5D%20example%20%5Bdot%5D%20com" class="mail JSnocheck" title="foo [at] example [dot] com">&lt;script&gt;alert(&#039;&quot;alert&quot;&#039;);&lt;/script&gt;</a>';
$this->assertEqual($p->doc,$expect);
}