From 16f15a8172591c8e5725677b192ec836030b424a Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 14 May 2012 21:56:38 +0200 Subject: empty ID in wl() will be treated as $conf['start'] --- _test/tests/inc/common_wl.test.php | 148 +++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 _test/tests/inc/common_wl.test.php (limited to '_test/tests') diff --git a/_test/tests/inc/common_wl.test.php b/_test/tests/inc/common_wl.test.php new file mode 100644 index 000000000..2e34dcae3 --- /dev/null +++ b/_test/tests/inc/common_wl.test.php @@ -0,0 +1,148 @@ +assertEquals(DOKU_BASE . DOKU_SCRIPT . '?id=start' , wl()); + } + + function test_wl_empty_rewrite1() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 1; + $conf['start'] = 'start'; + + $this->assertEquals(DOKU_BASE . 'start' , wl()); + } + + function test_wl_empty_rewrite2() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 2; + $conf['start'] = 'start'; + + $this->assertEquals(DOKU_BASE . DOKU_SCRIPT . '/start' , wl()); + } + + function test_wl_id() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some'; + $this->assertEquals($expect, wl('some')); + } + + function test_wl_id_ns() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:some'; + $this->assertEquals($expect, wl('some:some')); + } + + function test_wl_id_ns_start() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:'; + $this->assertEquals($expect, wl('some:')); + } + + function test_wl_args_array() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $args = array('a' => 'b', 'c' => 'd', 'q' => '&รค'); + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d&q=%26%C3%A4'; + $this->assertEquals($expect, wl('some:', $args)); + } + + function test_wl_args_string() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $args = 'a=b&c=d'; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d'; + $this->assertEquals($expect, wl('some:', $args)); + } + + function test_wl_args_comma_string() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $args = 'a=b,c=d'; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d'; + $this->assertEquals($expect, wl('some:', $args)); + } + + function test_wl_abs() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $expect = DOKU_URL . DOKU_SCRIPT . '?id=some:'; + $this->assertEquals($expect, wl('some:', '', true)); + } + + function test_wl_sep() { + global $conf; + $conf['useslash'] = 0; + $conf['userewrite'] = 0; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d'; + $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&')); + } + + function test_wl_useslash() { + global $conf; + $conf['useslash'] = 1; + $conf['userewrite'] = 0; + + $expect = DOKU_BASE . DOKU_SCRIPT . '?id=some:&a=b&c=d'; + $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&')); + } + + function test_wl_useslash_rewrite1() { + global $conf; + $conf['useslash'] = 1; + $conf['userewrite'] = 1; + + $expect = DOKU_BASE . 'some/?a=b&c=d'; + $this->assertEquals($expect, wl('some:', 'a=b,c=d', false, '&')); + } + + function test_wl_useslash_rewrite1_sub_page() { + global $conf; + $conf['useslash'] = 1; + $conf['userewrite'] = 1; + + $expect = DOKU_BASE . 'some/one?a=b&c=d'; + $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&')); + } + + function test_wl_useslash_rewrite2() { + global $conf; + $conf['useslash'] = 1; + $conf['userewrite'] = 2; + + $expect = DOKU_BASE . DOKU_SCRIPT . '/some/one?a=b&c=d'; + $this->assertEquals($expect, wl('some:one', 'a=b,c=d', false, '&')); + } + + + +} \ No newline at end of file -- cgit v1.2.3