diff options
author | Andreas Gohr <andi@splitbrain.org> | 2014-03-14 17:09:29 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2014-03-14 17:09:29 +0100 |
commit | 3275c5d6feb683bf4151f7d4867b10431b254d1e (patch) | |
tree | 4fd5e9ecf9165eb1b7cddd3d2bb1ae1330db92ab /_test | |
parent | 8fcb305db0081dacd8e8ad0583da5ecc6c6837dc (diff) | |
parent | 1359eacbdbff842b241a85ea274a00982fec9267 (diff) | |
download | rpg-3275c5d6feb683bf4151f7d4867b10431b254d1e.tar.gz rpg-3275c5d6feb683bf4151f7d4867b10431b254d1e.tar.bz2 |
Merge branch 'master' into diff_navigation
* master: (103 commits)
Add a basic test case for the cache
Events: Trigger a warning if the default action is not callable
Fix caching (make the event callback public again)
translation update
translation update
translation update
translation update
translation update
translation update
translation update
avoid HTTP image screenshot urls. closes #595
translation update
Extension manager: Fix cache extension to be .repo
adjusted the office type color again
another instance of empty() where an array key might not exist
remove placeholder van denied.txt
updated file icons once more
removed 'not logged in' text, loginform is shown already
Revert "added stripped bit to language file"
fixed index file
...
Conflicts:
inc/html.php
Diffstat (limited to '_test')
-rw-r--r-- | _test/core/DokuWikiTest.php | 3 | ||||
-rw-r--r-- | _test/tests/inc/cache_use.test.php | 36 | ||||
-rw-r--r-- | _test/tests/inc/parserutils_get_renderer.test.php | 83 |
3 files changed, 122 insertions, 0 deletions
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(); } } 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 @@ +<?php + +/** + * Class cache_use_test + * + * Tests if caching can actually be used + */ +class cache_use_test extends DokuWikiTest { + /** @var cache_renderer $cache */ + private $cache; + + function setUp() { + global $ID; + parent::setUp(); + + $ID = 'cached'; + $file = wikiFN($ID); + + saveWikiText($ID, 'Content', 'Created'); + // set the modification time a second in the past in order to ensure that the cache is newer than the page + touch($file, time()-1); + + # Create cache. Note that the metadata cache is used as the xhtml cache triggers metadata rendering + $this->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 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..69aeb3b19 --- /dev/null +++ b/_test/tests/inc/parserutils_get_renderer.test.php @@ -0,0 +1,83 @@ +<?php + +class parserutils_get_renderer_test extends DokuWikiTest { + + private $plugin_controller; + + // test default behaviour / usual settings + function test_p_get_renderer_normal() { + global $conf; + + $old_conf = $conf; + $conf['renderer_xhtml'] = 'xhtml'; + + $this->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 + /** + * @expectedException PHPUnit_Framework_Error + * @expectedExceptionCode E_USER_WARNING + */ + 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: |