From 2d6df7955d82d34f7a58b289fa04755c5ab9146e Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 00:49:18 +0100 Subject: added tests for Doku_Renderer::_resolveInterWiki --- .../inc/parser/renderer_resolveinterwiki.test.php | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 _test/tests/inc/parser/renderer_resolveinterwiki.test.php (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php new file mode 100644 index 000000000..5ce54fac6 --- /dev/null +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -0,0 +1,54 @@ +interwiki = getInterwiki(); + $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; + $Renderer->interwiki['slash'] = '/test'; + $Renderer->interwiki['onlytext'] = 'onlytext'; + + //var_dump($Renderer->interwiki); + + $tests = array( + // shortcut, reference and expected + array('wp', 'foo @+%/', 'http://en.wikipedia.org/wiki/foo @+%/'), + array('amazon', 'foo @+%/', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/'), + array('doku', 'foo @+%/', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F'), + //ToDo: Check needed, is double slash in path desired + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), + array('scheme', 'ftp://foo @+%/', 'ftp://example.com'), + //relative url + array('slash', 'foo @+%/', '/testfoo%20%40%2B%25%2F'), + //dokuwiki id's + array('onlytext', 'foo @+%/', 'onlytextfoo%20%40%2B%25%2F'), + array('user', 'foo @+%/', 'wiki:users:foo%20%40%2B%25%2F') + ); + + foreach($tests as $test) { + $url = $Renderer->_resolveInterWiki($test[0], $test[1]); + + $this->assertEquals($test[2], $url); + } + } + + function testNonexisting() { + $Renderer = new Doku_Renderer(); + $Renderer->interwiki = getInterwiki(); + + $shortcut = 'nonexisting'; + $reference = 'foo @+%/'; + $url = $Renderer->_resolveInterWiki($shortcut, $reference); + $expected = 'http://www.google.com/search?q=foo%20%40%2B%25%2F&btnI=lucky'; + + $this->assertEquals($expected, $url); + } + +} \ No newline at end of file -- cgit v1.2.3 From 2345e871e407dbece52f3181cd8b077f07cbb0c1 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:11:15 +0100 Subject: wikilink creating refactored to _resolveinterwiki(). Added DOKU_BASE for local target --- .../inc/parser/renderer_resolveinterwiki.test.php | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index 5ce54fac6..f17838f92 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -7,29 +7,28 @@ require_once DOKU_INC . 'inc/parser/renderer.php'; */ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { - function testDefaults() { $Renderer = new Doku_Renderer(); $Renderer->interwiki = getInterwiki(); $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; - $Renderer->interwiki['slash'] = '/test'; - $Renderer->interwiki['onlytext'] = 'onlytext'; - - //var_dump($Renderer->interwiki); + $Renderer->interwiki['withslash'] = '/test'; + $Renderer->interwiki['onlytext'] = 'onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = 'anyns:{NAME}?do=edit'; $tests = array( // shortcut, reference and expected - array('wp', 'foo @+%/', 'http://en.wikipedia.org/wiki/foo @+%/'), - array('amazon', 'foo @+%/', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/'), - array('doku', 'foo @+%/', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F'), + array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), + array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), + array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), //ToDo: Check needed, is double slash in path desired array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), - array('scheme', 'ftp://foo @+%/', 'ftp://example.com'), + array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url - array('slash', 'foo @+%/', '/testfoo%20%40%2B%25%2F'), + array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), //dokuwiki id's - array('onlytext', 'foo @+%/', 'onlytextfoo%20%40%2B%25%2F'), - array('user', 'foo @+%/', 'wiki:users:foo%20%40%2B%25%2F') + array('onlytext', 'foo @+%#txt', '/tmp/doku.php?id=onlytextfoo%20%40%2B%25#txt'), + array('user', 'foo @+%#txt', '/tmp/doku.php?id=wiki:users:foo%20%40%2B%25#txt'), + array('withquery', 'foo @+%#txt', '/tmp/doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 4485a8917160fb9f955e5b8aa28c1a5499c608b0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:28:09 +0100 Subject: Fix double slash in coral interwikilink --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index f17838f92..ea4f99511 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -20,8 +20,7 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('wp', 'foo @+%/#txt', 'http://en.wikipedia.org/wiki/foo @+%/#txt'), array('amazon', 'foo @+%/#txt', 'http://www.amazon.com/exec/obidos/ASIN/foo%20%40%2B%25%2F/splitbrain-20/#txt'), array('doku', 'foo @+%/#txt', 'http://www.dokuwiki.org/foo%20%40%2B%25%2F#txt'), - //ToDo: Check needed, is double slash in path desired - array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090//path/naar/?query=foo%20%40%2B%25%2F'), + array('coral', 'http://example.com:83/path/naar/?query=foo%20%40%2B%25%2F', 'http://example.com.83.nyud.net:8090/path/naar/?query=foo%20%40%2B%25%2F'), array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), -- cgit v1.2.3 From ddb55c702f2393a435c309fd7d4e169acb2675f7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 11:29:33 +0100 Subject: Use DOKU_BASE in resolveinterwiki unittest --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index ea4f99511..a71895b34 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -25,9 +25,9 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), //dokuwiki id's - array('onlytext', 'foo @+%#txt', '/tmp/doku.php?id=onlytextfoo%20%40%2B%25#txt'), - array('user', 'foo @+%#txt', '/tmp/doku.php?id=wiki:users:foo%20%40%2B%25#txt'), - array('withquery', 'foo @+%#txt', '/tmp/doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo%20%40%2B%25#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo%20%40%2B%25#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 6496c33fc8e98f6e3acaaa5db0234d9c07bec4fe Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sat, 15 Feb 2014 14:34:26 +0100 Subject: interwiki : prefixed configurls handled as wikilinks --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index a71895b34..e78930934 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -12,8 +12,8 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { $Renderer->interwiki = getInterwiki(); $Renderer->interwiki['scheme'] = '{SCHEME}://example.com'; $Renderer->interwiki['withslash'] = '/test'; - $Renderer->interwiki['onlytext'] = 'onlytext{NAME}'; //with {URL} double urlencoded - $Renderer->interwiki['withquery'] = 'anyns:{NAME}?do=edit'; + $Renderer->interwiki['onlytext'] = ':onlytext{NAME}'; //with {URL} double urlencoded + $Renderer->interwiki['withquery'] = ':anyns:{NAME}?do=edit'; $tests = array( // shortcut, reference and expected @@ -24,10 +24,11 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('scheme', 'ftp://foo @+%/#txt', 'ftp://example.com#txt'), //relative url array('withslash', 'foo @+%/#txt', '/testfoo%20%40%2B%25%2F#txt'), + array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), //dokuwiki id's - array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo%20%40%2B%25#txt'), - array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo%20%40%2B%25#txt'), - array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo%20%40%2B%25&do=edit#txt') + array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo#txt'), + array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') ); foreach($tests as $test) { -- cgit v1.2.3 From 04180aa92fd6a23e4a6c154bc248e7b09d60d21d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Feb 2014 16:57:04 +0100 Subject: unit test for FS#2173 --- _test/tests/inc/utf8_strtolower.test.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _test/tests/inc/utf8_strtolower.test.php (limited to '_test') diff --git a/_test/tests/inc/utf8_strtolower.test.php b/_test/tests/inc/utf8_strtolower.test.php new file mode 100644 index 000000000..85f5b270b --- /dev/null +++ b/_test/tests/inc/utf8_strtolower.test.php @@ -0,0 +1,23 @@ + 'αρχιτεκτονική μελέτη', // FS#2173 + ); + + foreach($data as $input => $expected) { + $this->assertEquals($expected, utf8_strtolower($input)); + } + + // just make sure our data was correct + if(function_exists('mb_strtolower')) { + foreach($data as $input => $expected) { + $this->assertEquals($expected, mb_strtolower($input, 'utf-8')); + } + } + } +} \ No newline at end of file -- cgit v1.2.3 From 118e00521560a4a93c92ba7439e5cf5463e0efe7 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 17 Feb 2014 00:51:10 +0100 Subject: update unittest with interwiki.conf change as well --- _test/tests/inc/parser/renderer_resolveinterwiki.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php index e78930934..7b43b6d62 100644 --- a/_test/tests/inc/parser/renderer_resolveinterwiki.test.php +++ b/_test/tests/inc/parser/renderer_resolveinterwiki.test.php @@ -27,7 +27,7 @@ class Test_resolveInterwiki extends PHPUnit_Framework_TestCase { array('skype', 'foo @+%/#txt', 'skype:foo @+%/#txt'), //dokuwiki id's array('onlytext', 'foo @+%#txt', DOKU_BASE.'doku.php?id=onlytextfoo#txt'), - array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=wiki:users:foo#txt'), + array('user', 'foo @+%#txt', DOKU_BASE.'doku.php?id=user:foo#txt'), array('withquery', 'foo @+%#txt', DOKU_BASE.'doku.php?id=anyns:foo&do=edit#txt') ); -- cgit v1.2.3 From 5d873dd4ce31c79403a01ac0e40ff148be282592 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 23 Feb 2014 10:09:11 +0100 Subject: fixed test cases for last commit --- _test/tests/inc/common_pageinfo.test.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/common_pageinfo.test.php b/_test/tests/inc/common_pageinfo.test.php index 0a1ea0a8f..2b230d9ce 100644 --- a/_test/tests/inc/common_pageinfo.test.php +++ b/_test/tests/inc/common_pageinfo.test.php @@ -38,6 +38,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['writable'] = true; $info['editable'] = true; $info['lastmod'] = false; + $info['currentrev'] = false; $info['meta'] = array(); $info['ip'] = null; $info['user'] = null; @@ -77,6 +78,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['filepath'] = $filename; $info['exists'] = true; $info['lastmod'] = $rev; + $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); $this->assertEquals($info, pageinfo()); @@ -101,6 +103,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['filepath'] = $filename; $info['exists'] = true; $info['lastmod'] = $rev; + $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); $info['rev'] = ''; @@ -131,6 +134,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['namespace'] = 'wiki'; $info['meta'] = p_get_metadata($ID); $info['rev'] = $REV; + $info['currentrev'] = $rev; $info['filepath'] = str_replace('pages','attic',substr($filename,0,-3).$REV.'.txt.gz'); $this->assertEquals($info, pageinfo()); @@ -153,6 +157,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['namespace'] = 'wiki'; $info['exists'] = true; $info['lastmod'] = $rev; + $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); $info['filepath'] = $filename; @@ -197,6 +202,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['filepath'] = $filename; $info['exists'] = true; $info['lastmod'] = $rev; + $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); // need $INFO set correctly for addLogEntry() global $INFO; @@ -226,6 +232,7 @@ class common_pageinfo_test extends DokuWikiTest { touch($filename,$now); $info['lastmod'] = $now; + $info['currentrev'] = $now; $info['meta']['last_change'] = false; $info['ip'] = null; $info['user'] = null; @@ -251,6 +258,7 @@ class common_pageinfo_test extends DokuWikiTest { $info['filepath'] = $filename; $info['exists'] = true; $info['lastmod'] = $rev; + $info['currentrev'] = $rev; $info['meta'] = p_get_metadata($ID); // setup a draft, make it more recent than the current page -- cgit v1.2.3 From 9377d909ce85b1b96b0e953b3c09a2539797d54b Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 03:00:26 +0000 Subject: add test for p_get_renderer() with fallback --- _test/tests/inc/parserutils_get_renderer.test.php | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 _test/tests/inc/parserutils_get_renderer.test.php (limited to '_test') diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php new file mode 100644 index 000000000..0f373227d --- /dev/null +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -0,0 +1,79 @@ +assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml')); + + $conf = $old_conf; + } + + // test get a renderer plugin + function test_p_get_renderer_plugin() { + global $conf; + global $plugin_controller; + + $old_conf = $conf; + $conf['renderer_xhtml'] = 'get_renderer_test'; + $this->plugin_controller = $plugin_controller; + $plugin_controller = $this; + + $this->assertInstanceOf('renderer_plugin_test', p_get_renderer('xhtml')); + + $conf = $old_conf; + $plugin_controller = $this->plugin_controller; + } + + // test fallback succeeds + function test_p_get_renderer_fallback() { + global $conf; + + $old_conf = $conf; + $conf['renderer_xhtml'] = 'badvalue'; + + $this->assertInstanceOf('Doku_Renderer_xhtml', p_get_renderer('xhtml')); + + $conf = $old_conf; + } + + // test fallback fails + function test_p_get_renderer_fallback_fail() { + global $conf; + + $old_conf = $conf; + $conf['renderer_junk'] = 'badvalue'; + + $this->assertNull(p_get_renderer('junk')); + + $conf = $old_conf; + } + + // wrapper function for the fake plugin controller, return $this for the fake syntax of this test + function load($type,$name,$new=false,$disabled=false){ + if ($name == 'get_renderer_test') { + return new renderer_plugin_test(); + } else { + return $this->plugin_controller->load($type, $name, $new, $disabled); + } + } + } + +require_once DOKU_INC . 'inc/parser/xhtml.php'; + +class renderer_plugin_test extends Doku_Renderer_xhtml { + + function canRender($format) { + return ($format=='xhtml'); + } + +} + +// vim:ts=4:sw=4:et: -- cgit v1.2.3 From f3283f02766b2a2730b81c5a5a0b0a6240af054c Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Tue, 25 Feb 2014 21:15:43 +0000 Subject: change to an Exception and expect it --- _test/tests/inc/parserutils_get_renderer.test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to '_test') diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php index 0f373227d..540063e19 100644 --- a/_test/tests/inc/parserutils_get_renderer.test.php +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -45,6 +45,10 @@ class parserutils_get_renderer_test extends DokuWikiTest { } // test fallback fails + /** + * @expectedException Exception + * @expectedExceptionCode E_USER_WARNING + */ function test_p_get_renderer_fallback_fail() { global $conf; -- cgit v1.2.3 From a049856df3f316114a9d936d830d5b6d419b11e6 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Wed, 26 Feb 2014 01:12:33 +0000 Subject: revert back to trigger error --- _test/tests/inc/parserutils_get_renderer.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/tests/inc/parserutils_get_renderer.test.php b/_test/tests/inc/parserutils_get_renderer.test.php index 540063e19..69aeb3b19 100644 --- a/_test/tests/inc/parserutils_get_renderer.test.php +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -46,7 +46,7 @@ class parserutils_get_renderer_test extends DokuWikiTest { // test fallback fails /** - * @expectedException Exception + * @expectedException PHPUnit_Framework_Error * @expectedExceptionCode E_USER_WARNING */ function test_p_get_renderer_fallback_fail() { -- cgit v1.2.3 From 0499ebedfee66081086cd4ec5951365341072c88 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Mar 2014 17:00:09 +0100 Subject: added (failing) test case for broken jquery ui compression --- _test/tests/lib/exe/css_css_compress.test.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '_test') diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index a614ea2fd..ba103813a 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -102,6 +102,13 @@ class css_css_compress_test extends DokuWikiTest { $this->assertEquals($expected, $input); } + function test_data() { + $input = 'list-style-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; + $expect = 'list-style-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);'; + + $this->assertEquals($expect, css_compress($input)); + } + } //Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From fe5a50c39e9bd837f887ea7ad8335717a6c6ab92 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 5 Mar 2014 19:37:43 +0100 Subject: fix single line comments in CSS compression double slashes in url() always have to be ignored --- _test/tests/lib/exe/css_css_compress.test.php | 32 +++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to '_test') diff --git a/_test/tests/lib/exe/css_css_compress.test.php b/_test/tests/lib/exe/css_css_compress.test.php index ba103813a..f0eb17968 100644 --- a/_test/tests/lib/exe/css_css_compress.test.php +++ b/_test/tests/lib/exe/css_css_compress.test.php @@ -10,33 +10,47 @@ class css_css_compress_test extends DokuWikiTest { * line *test* * check */'; - $this->assertEquals(css_compress($text), ''); + $this->assertEquals('', css_compress($text)); } function test_mlcom2(){ $text = '#comment/* */ { color: lime; }'; - $this->assertEquals(css_compress($text), '#comment/* */{color:lime;}'); + $this->assertEquals('#comment/* */{color:lime;}', css_compress($text)); } function test_slcom1(){ $text = '// this is a comment'; - $this->assertEquals(css_compress($text), ''); + $this->assertEquals('', css_compress($text)); } function test_slcom2(){ $text = '#foo { color: lime; // another comment }'; - $this->assertEquals(css_compress($text), '#foo{color:lime;}'); + $this->assertEquals('#foo{color:lime;}', css_compress($text)); } function test_slcom3(){ $text = '#foo { - background-image: url(http://foo.bar/baz.jpg); + background-image: url(http://foo.bar/baz.jpg); // this is a comment }'; - $this->assertEquals(css_compress($text), '#foo{background-image:url(http://foo.bar/baz.jpg);}'); + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_slcom4(){ + $text = '#foo { + background-image: url(http://foo.bar/baz.jpg); background-image: url(http://foo.bar/baz.jpg); // this is a comment + }'; + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); + } + + function test_slcom5(){ + $text = '#foo { + background-image: url(http://foo.bar/baz.jpg); // background-image: url(http://foo.bar/baz.jpg); this is all commented + }'; + $this->assertEquals('#foo{background-image:url(http://foo.bar/baz.jpg);}', css_compress($text)); } function test_hack(){ @@ -44,7 +58,7 @@ class css_css_compress_test extends DokuWikiTest { /* \\*/ display: inline; /* */'; - $this->assertEquals(css_compress($text), '/* \\*/display:inline;/* */'); + $this->assertEquals('/* \\*/display:inline;/* */', css_compress($text)); } function test_hack2(){ @@ -54,12 +68,12 @@ class css_css_compress_test extends DokuWikiTest { height: 450px; } /**/'; - $this->assertEquals(css_compress($text), '/*\\*/* html .page{height:450px;}/**/'); + $this->assertEquals('/*\\*/* html .page{height:450px;}/**/', css_compress($text)); } function test_nl1(){ $text = "a{left:20px;\ntop:20px}"; - $this->assertEquals(css_compress($text), 'a{left:20px;top:20px}'); + $this->assertEquals('a{left:20px;top:20px}', css_compress($text)); } function test_shortening() { -- cgit v1.2.3 From c01cdb709fd0bf8c91333c5134743e33bf587833 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Thu, 6 Mar 2014 19:58:09 +0000 Subject: Fix unittests broken by previous two commits Mostly this is for unit tests which use of \$_SERVER['REMOTE_USER'] It ensures the reference/alias connection between \$INPUT->server and \$_SERVER is renewed before each test. Tests using TestRequest class will replace this \$INPUT with their own. --- _test/core/DokuWikiTest.php | 3 +++ 1 file changed, 3 insertions(+) (limited to '_test') diff --git a/_test/core/DokuWikiTest.php b/_test/core/DokuWikiTest.php index 91eb5293b..f4521256a 100644 --- a/_test/core/DokuWikiTest.php +++ b/_test/core/DokuWikiTest.php @@ -115,5 +115,8 @@ abstract class DokuWikiTest extends PHPUnit_Framework_TestCase { // reload language $local = $conf['lang']; trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true); + + global $INPUT; + $INPUT = new Input(); } } -- cgit v1.2.3 From 16ca217de8ce72a9c736f35f1a62718437369d88 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 14 Mar 2014 13:08:32 +0100 Subject: Add a basic test case for the cache This very basic test ensures that the useCache method works as expected for simple scenarios. This test case fails without commit a8795974051a91137b01ff88dbf5586a647b24ce and then also triggers the warning that was introduced in bc2ddb548f71b1a822dd03c3bc7c3c0e7cd9b152 --- _test/tests/inc/cache_use.test.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 _test/tests/inc/cache_use.test.php (limited to '_test') diff --git a/_test/tests/inc/cache_use.test.php b/_test/tests/inc/cache_use.test.php new file mode 100644 index 000000000..f5349df13 --- /dev/null +++ b/_test/tests/inc/cache_use.test.php @@ -0,0 +1,36 @@ +cache = new cache_renderer($ID, $file, 'metadata'); + $this->cache->storeCache('Test'); + } + + function test_use() { + $this->assertTrue($this->cache->useCache()); + } + + + function test_purge() { + $this->assertFalse($this->cache->useCache(array('purge' => true))); + } +} \ No newline at end of file -- cgit v1.2.3 From f8fb2d1811251304687b805a60b489f63cb5c4fb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 15 Mar 2014 21:29:33 +0100 Subject: strip sourcemaps in CSS and JS #601 source maps are invalid for our dispatched sources and may even cause problems. this makes sure any sourcemap declarations are stripped from the output --- _test/tests/inc/common_stripsourcemaps.test.php | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 _test/tests/inc/common_stripsourcemaps.test.php (limited to '_test') diff --git a/_test/tests/inc/common_stripsourcemaps.test.php b/_test/tests/inc/common_stripsourcemaps.test.php new file mode 100644 index 000000000..c6a915dcf --- /dev/null +++ b/_test/tests/inc/common_stripsourcemaps.test.php @@ -0,0 +1,29 @@ +assertEquals($expect, $text); + } + +} \ No newline at end of file -- cgit v1.2.3