diff options
Diffstat (limited to '_test/tests/inc')
-rw-r--r-- | _test/tests/inc/auth_aclcheck.test.php | 27 | ||||
-rw-r--r-- | _test/tests/inc/common_cleanText.test.php | 6 | ||||
-rw-r--r-- | _test/tests/inc/events_nested.test.php | 36 | ||||
-rw-r--r-- | _test/tests/inc/httpclient_http.test.php | 15 | ||||
-rw-r--r-- | _test/tests/inc/input.test.php | 12 | ||||
-rw-r--r-- | _test/tests/inc/pageutils_findnearest.test.php | 40 | ||||
-rw-r--r-- | _test/tests/inc/template_sidebar.test.php | 40 |
7 files changed, 170 insertions, 6 deletions
diff --git a/_test/tests/inc/auth_aclcheck.test.php b/_test/tests/inc/auth_aclcheck.test.php index ea48ec6a5..991f82da7 100644 --- a/_test/tests/inc/auth_aclcheck.test.php +++ b/_test/tests/inc/auth_aclcheck.test.php @@ -235,6 +235,33 @@ class auth_acl_test extends DokuWikiTest { $this->assertEquals(auth_aclcheck('namespace:*', 'jill',array('foo','roots')), AUTH_ADMIN); } + function test_wildcards(){ + global $conf; + global $AUTH_ACL; + global $USERINFO; + $conf['useacl'] = 1; + + $_SERVER['REMOTE_USER'] = 'john'; + $USERINFO['grps'] = array('test','töst','foo bar'); + $AUTH_ACL = auth_loadACL(); // default test file + + // default setting + $this->assertEquals(AUTH_UPLOAD, auth_aclcheck('page', $_SERVER['REMOTE_USER'], $USERINFO['grps'])); + + // user namespace + $this->assertEquals(AUTH_DELETE, auth_aclcheck('users:john:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps'])); + $this->assertEquals(AUTH_READ, auth_aclcheck('users:john:foo', 'schmock', array())); + + // group namespace + $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:test:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps'])); + $this->assertEquals(AUTH_READ, auth_aclcheck('groups:test:foo', 'schmock', array())); + $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:toest:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps'])); + $this->assertEquals(AUTH_READ, auth_aclcheck('groups:toest:foo', 'schmock', array())); + $this->assertEquals(AUTH_DELETE, auth_aclcheck('groups:foo_bar:foo', $_SERVER['REMOTE_USER'], $USERINFO['grps'])); + $this->assertEquals(AUTH_READ, auth_aclcheck('groups:foo_bar:foo', 'schmock', array())); + + } + } //Setup VIM: ex: et ts=4 : diff --git a/_test/tests/inc/common_cleanText.test.php b/_test/tests/inc/common_cleanText.test.php index 00e70d4c7..9d4494332 100644 --- a/_test/tests/inc/common_cleanText.test.php +++ b/_test/tests/inc/common_cleanText.test.php @@ -3,11 +3,7 @@ class common_cleanText_test extends DokuWikiTest { function test_unix(){ - $unix = 'one - two - - three'; - + $unix = "one\n two\n\n three"; $this->assertEquals($unix,cleanText($unix)); } diff --git a/_test/tests/inc/events_nested.test.php b/_test/tests/inc/events_nested.test.php new file mode 100644 index 000000000..fe5e395bb --- /dev/null +++ b/_test/tests/inc/events_nested.test.php @@ -0,0 +1,36 @@ +<?php + +/** + * This tests if event handlers can trigger the same event again. + * This is used by plugins that modify cache handling and use metadata + * for checking cache validity which triggers another cache use event. + */ +class events_nested_test extends DokuWikiTest { + function test_nested_events() { + global $EVENT_HANDLER; + $firstcount = 0; + $secondcount = 0; + + $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, + function() use (&$firstcount) { + $firstcount++; + if ($firstcount == 1) { + $param = array(); + trigger_event('NESTED_EVENT', $param); + } + } + ); + + $EVENT_HANDLER->register_hook('NESTED_EVENT', 'BEFORE', null, + function() use (&$secondcount) { + $secondcount++; + } + ); + + $param = array(); + trigger_event('NESTED_EVENT', $param); + + $this->assertEquals(2, $firstcount); + $this->assertEquals(2, $secondcount); + } +} diff --git a/_test/tests/inc/httpclient_http.test.php b/_test/tests/inc/httpclient_http.test.php index 9cae3736a..9959a1f06 100644 --- a/_test/tests/inc/httpclient_http.test.php +++ b/_test/tests/inc/httpclient_http.test.php @@ -124,6 +124,11 @@ class httpclient_http_test extends DokuWikiTest { $http->max_bodysize = 250; $data = $http->get($this->server.'/stream/30'); $this->assertTrue($data === false, 'HTTP response'); + $http->max_bodysize_abort = false; + $data = $http->get($this->server.'/stream/30'); + $this->assertFalse($data === false, 'HTTP response'); + /* should read no more than max_bodysize+1 */ + $this->assertLessThanOrEqual(251,strlen($data)); } /** @@ -176,5 +181,15 @@ class httpclient_http_test extends DokuWikiTest { $this->assertArrayHasKey('foo',$http->resp_headers); $this->assertEquals('bar',$http->resp_headers['foo']); } + + /** + * @group internet + */ + function test_chunked(){ + $http = new HTTPClient(); + $data = $http->get('http://whoopdedo.org/cgi-bin/chunked/2550'); + $this->assertFalse($data === false, 'HTTP response'); + $this->assertEquals(2550,strlen($data)); + } } //Setup VIM: ex: et ts=4 : diff --git a/_test/tests/inc/input.test.php b/_test/tests/inc/input.test.php index 627af3a2b..761b7ddbc 100644 --- a/_test/tests/inc/input.test.php +++ b/_test/tests/inc/input.test.php @@ -95,6 +95,11 @@ class input_test extends DokuWikiTest { $this->assertSame(1, $INPUT->get->int('get', false)); $this->assertSame(0, $INPUT->int('array')); + + $this->assertSame(0, $INPUT->int('zero', -1)); + $this->assertSame(-1, $INPUT->int('empty', -1)); + $this->assertSame(-1, $INPUT->int('zero', -1, true)); + $this->assertSame(-1, $INPUT->int('empty', -1, true)); } public function test_arr() { @@ -155,6 +160,11 @@ class input_test extends DokuWikiTest { $this->assertSame(false, $INPUT->post->bool('get')); $this->assertSame(true, $INPUT->post->bool('post')); + + $this->assertSame(false, $INPUT->bool('zero', -1)); + $this->assertSame(-1, $INPUT->bool('empty', -1)); + $this->assertSame(-1, $INPUT->bool('zero', -1, true)); + $this->assertSame(-1, $INPUT->bool('empty', -1, true)); } public function test_remove() { @@ -203,4 +213,4 @@ class input_test extends DokuWikiTest { $this->assertEquals('bla',$test); } -}
\ No newline at end of file +} diff --git a/_test/tests/inc/pageutils_findnearest.test.php b/_test/tests/inc/pageutils_findnearest.test.php new file mode 100644 index 000000000..e129b5e58 --- /dev/null +++ b/_test/tests/inc/pageutils_findnearest.test.php @@ -0,0 +1,40 @@ +<?php + +class pageutils_findnearest_test extends DokuWikiTest { + function testNoSidebar() { + global $ID; + + $ID = 'foo:bar:baz:test'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals(false, $sidebar); + } + + function testExistingSidebars() { + global $ID; + + saveWikiText('sidebar', 'topsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals('sidebar', $sidebar); + + $ID = 'foo'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals('sidebar', $sidebar); + + saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals('foo:bar:sidebar', $sidebar); + + $ID = 'foo:bar:test'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals('foo:bar:sidebar', $sidebar); + + $ID = 'foo'; + $sidebar = page_findnearest('sidebar'); + $this->assertEquals('sidebar', $sidebar); + } + +} diff --git a/_test/tests/inc/template_sidebar.test.php b/_test/tests/inc/template_sidebar.test.php new file mode 100644 index 000000000..56153894a --- /dev/null +++ b/_test/tests/inc/template_sidebar.test.php @@ -0,0 +1,40 @@ +<?php + +class template_sidebar_test extends DokuWikiTest { + function testNoSidebar() { + global $ID; + + $ID = 'foo:bar:baz:test'; + $sidebar = tpl_sidebar(false); + $this->assertEquals('',$sidebar); + } + + function testExistingSidebars() { + global $ID; + + saveWikiText('sidebar', 'topsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = tpl_sidebar(false); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + + $ID = 'foo'; + $sidebar = tpl_sidebar(false); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + + saveWikiText('foo:bar:sidebar', 'bottomsidebar-test', ''); + + $ID = 'foo:bar:baz:test'; + $sidebar = tpl_sidebar(false); + $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + + $ID = 'foo:bar:test'; + $sidebar = tpl_sidebar(false); + $this->assertTrue(strpos($sidebar, 'bottomsidebar-test') > 0); + + $ID = 'foo'; + $sidebar = tpl_sidebar(false); + $this->assertTrue(strpos($sidebar, 'topsidebar-test') > 0); + } + +} |