summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
Diffstat (limited to '_test')
-rw-r--r--_test/bootstrap.php4
-rw-r--r--_test/core/phpQuery-onefile.php2
-rw-r--r--_test/tests/inc/html_hilight.test.php32
-rw-r--r--_test/tests/inc/input.test.php19
-rw-r--r--_test/tests/inc/subscription_set.test.php20
-rw-r--r--_test/tests/inc/tarlib.test.php0
-rw-r--r--_test/tests/inc/template_include_page.test.php (renamed from _test/tests/inc/template_sidebar.test.php)16
-rw-r--r--_test/tests/inc/utf8_basename.test.php22
-rw-r--r--_test/tests/lib/exe/js_js_compress.test.php26
9 files changed, 131 insertions, 10 deletions
diff --git a/_test/bootstrap.php b/_test/bootstrap.php
index 58ad6a0d7..310b3627a 100644
--- a/_test/bootstrap.php
+++ b/_test/bootstrap.php
@@ -110,3 +110,7 @@ $dh->close();
// load dw
require_once(DOKU_INC.'inc/init.php');
+// load the parser so $PARSER_MODES is defined before the tests start
+// otherwise PHPUnit unsets $PARSER_MODES in some cases which breaks p_get_parsermodes()
+require_once(DOKU_INC.'inc/parser/parser.php');
+
diff --git a/_test/core/phpQuery-onefile.php b/_test/core/phpQuery-onefile.php
index 4c1dfa3da..402cf8e49 100644
--- a/_test/core/phpQuery-onefile.php
+++ b/_test/core/phpQuery-onefile.php
@@ -4206,7 +4206,7 @@ class phpQueryObject
.($node->getAttribute('id')
? '#'.$node->getAttribute('id'):'')
.($node->getAttribute('class')
- ? '.'.join('.', split(' ', $node->getAttribute('class'))):'')
+ ? '.'.join('.', explode(' ', $node->getAttribute('class'))):'')
.($node->getAttribute('name')
? '[name="'.$node->getAttribute('name').'"]':'')
.($node->getAttribute('value') && strpos($node->getAttribute('value'), '<'.'?php') === false
diff --git a/_test/tests/inc/html_hilight.test.php b/_test/tests/inc/html_hilight.test.php
index bb0cdd424..fc4eced67 100644
--- a/_test/tests/inc/html_hilight.test.php
+++ b/_test/tests/inc/html_hilight.test.php
@@ -97,4 +97,36 @@ class html_hilight_test extends DokuWikiTest {
html_hilight($html,'x/')
);
}
+
+ function testMB() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo <span.*>ДокуВики<\/span> bar/',
+ html_hilight($html,'ДокуВики')
+ );
+ }
+
+ function testMBright() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo <span.*>Доку<\/span>Вики bar/',
+ html_hilight($html,'Доку*')
+ );
+ }
+
+ function testMBleft() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo Доку<span.*>Вики<\/span> bar/',
+ html_hilight($html,'*Вики')
+ );
+ }
+
+ function testMBboth() {
+ $html = 'foo ДокуВики bar';
+ $this->assertRegExp(
+ '/foo До<span.*>куВи<\/span>ки bar/',
+ html_hilight($html,'*куВи*')
+ );
+ }
}
diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php
index 761b7ddbc..59b5ea4b9 100644
--- a/_test/tests/inc/input.test.php
+++ b/_test/tests/inc/input.test.php
@@ -12,7 +12,8 @@ class input_test extends DokuWikiTest {
'zero' => '0',
'one' => '1',
'empty' => '',
- 'emptya' => array()
+ 'emptya' => array(),
+ 'do' => array('save' => 'Speichern'),
);
public function test_str() {
@@ -213,4 +214,20 @@ class input_test extends DokuWikiTest {
$this->assertEquals('bla',$test);
}
+ public function test_extract(){
+ $_REQUEST = $this->data;
+ $_POST = $this->data;
+ $_GET = $this->data;
+ $INPUT = new Input();
+
+ $this->assertEquals('save', $INPUT->extract('do')->str('do'));
+ $this->assertEquals('', $INPUT->extract('emptya')->str('emptya'));
+ $this->assertEquals('foo', $INPUT->extract('string')->str('string'));
+ $this->assertEquals('foo', $INPUT->extract('array')->str('array'));
+
+ $this->assertEquals('save', $INPUT->post->extract('do')->str('do'));
+ $this->assertEquals('', $INPUT->post->extract('emptya')->str('emptya'));
+ $this->assertEquals('foo', $INPUT->post->extract('string')->str('string'));
+ $this->assertEquals('foo', $INPUT->post->extract('array')->str('array'));
+ }
}
diff --git a/_test/tests/inc/subscription_set.test.php b/_test/tests/inc/subscription_set.test.php
new file mode 100644
index 000000000..5c0a6c816
--- /dev/null
+++ b/_test/tests/inc/subscription_set.test.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Tests the subscription set function
+ */
+class subscription_set_test extends DokuWikiTest {
+ /**
+ * Tests, if overwriting subscriptions works even when subscriptions for the same
+ * user exist for two nested namespaces, this is a test for the bug described in FS#2580
+ */
+ function test_overwrite() {
+ subscription_set('admin', ':', 'digest', '123456789');
+ subscription_set('admin', ':wiki:', 'digest', '123456789');
+ subscription_set('admin', ':', 'digest', '1234', true);
+ subscription_set('admin', ':wiki:', 'digest', '1234', true);
+ $subscriptions = subscription_find(':wiki:', array('user' => 'admin'));
+ $this->assertCount(1, $subscriptions[':'], 'More than one subscription saved for the root namespace even though the old one should have been overwritten.');
+ $this->assertCount(1, $subscriptions[':wiki:'], 'More than one subscription saved for the wiki namespace even though the old one should have been overwritten.');
+ $this->assertCount(2, $subscriptions, 'Didn\'t find the expected two subscriptions');
+ }
+}
diff --git a/_test/tests/inc/tarlib.test.php b/_test/tests/inc/tarlib.test.php
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/_test/tests/inc/tarlib.test.php
diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_include_page.test.php
index 56153894a..47d4d46f1 100644
--- a/_test/tests/inc/template_sidebar.test.php
+++ b/_test/tests/inc/template_include_page.test.php
@@ -1,12 +1,12 @@
<?php
-class template_sidebar_test extends DokuWikiTest {
+class template_include_page_test extends DokuWikiTest {
function testNoSidebar() {
global $ID;
$ID = 'foo:bar:baz:test';
- $sidebar = tpl_sidebar(false);
- $this->assertEquals('',$sidebar);
+ $sidebar = tpl_include_page('sidebar', false, true);
+ $this->assertEquals('', $sidebar);
}
function testExistingSidebars() {
@@ -15,25 +15,25 @@ class template_sidebar_test extends DokuWikiTest {
saveWikiText('sidebar', 'topsidebar-test', '');
$ID = 'foo:bar:baz:test';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
$ID = 'foo';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', '');
$ID = 'foo:bar:baz:test';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
$ID = 'foo:bar:test';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0);
$ID = 'foo';
- $sidebar = tpl_sidebar(false);
+ $sidebar = tpl_include_page('sidebar', false, true);
$this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0);
}
diff --git a/_test/tests/inc/utf8_basename.test.php b/_test/tests/inc/utf8_basename.test.php
index 1cb5b5606..1544e9915 100644
--- a/_test/tests/inc/utf8_basename.test.php
+++ b/_test/tests/inc/utf8_basename.test.php
@@ -59,6 +59,28 @@ class utf8_basename_test extends DokuWikiTest {
array('\\this\\foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'),
array('/this\\foo/ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'),
array('/this/foo\\ДокуВики.test.Вик', '.Вик', 'ДокуВики.test'),
+
+ array('bar.test.png', '', 'bar.test.png'),
+ array('bar.test.png', '.png', 'bar.test'),
+
+ array('/bar.test.png', '', 'bar.test.png'),
+ array('/bar.test.png', '.png', 'bar.test'),
+ array('\\bar.test.png', '', 'bar.test.png'),
+ array('\\bar.test.png', '.png', 'bar.test'),
+ array('\\/bar.test.png', '', 'bar.test.png'),
+ array('\\/bar.test.png', '.png', 'bar.test'),
+ array('/\\bar.test.png', '', 'bar.test.png'),
+ array('/\\bar.test.png', '.png', 'bar.test'),
+
+ // PHP's basename does this too:
+ array('foo/', '', 'foo'),
+ array('foo\\', '', 'foo'),
+ array('foo\\/', '', 'foo'),
+ array('foo/\\', '', 'foo'),
+ array('foo.png/', '.png', 'foo'),
+ array('foo.png\\', '.png', 'foo'),
+ array('foo.png\\/', '.png', 'foo'),
+ array('foo.png/\\', '.png', 'foo'),
);
foreach($data as $test){
diff --git a/_test/tests/lib/exe/js_js_compress.test.php b/_test/tests/lib/exe/js_js_compress.test.php
index 49f93cc54..b1ae2a84f 100644
--- a/_test/tests/lib/exe/js_js_compress.test.php
+++ b/_test/tests/lib/exe/js_js_compress.test.php
@@ -118,6 +118,32 @@ class js_js_compress_test extends DokuWikiTest {
$this->assertEquals("var foo='this is a multiline string';",js_compress($text));
}
+ function test_nocompress(){
+ $text = <<<EOF
+var meh = 'test' ;
+
+/* BEGIN NOCOMPRESS */
+
+
+var foo = 'test' ;
+
+var bar = 'test' ;
+
+
+/* END NOCOMPRESS */
+
+var moh = 'test' ;
+EOF;
+ $out = <<<EOF
+var meh='test';
+var foo = 'test' ;
+
+var bar = 'test' ;
+var moh='test';
+EOF;
+
+ $this->assertEquals($out, js_compress($text));
+ }
/**
* Test the files provided with the original JsStrip