diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-06-16 11:51:28 -0700 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-06-16 11:51:28 -0700 |
commit | 3f314099e3286ad91de618473f073ee01947ebda (patch) | |
tree | 111336c9354e8d956bdf294b1740c2eb182b8087 /_test/tests | |
parent | 3394e804f34fc2636c519d9ec6e10e342adf520d (diff) | |
parent | 3074e3428bd5d1e38078dbac80a1eb9b96f917d7 (diff) | |
download | rpg-3f314099e3286ad91de618473f073ee01947ebda.tar.gz rpg-3f314099e3286ad91de618473f073ee01947ebda.tar.bz2 |
Merge pull request #180 from splitbrain/FS#2415
FS#2415, add $INFO to mediamanager
Diffstat (limited to '_test/tests')
-rw-r--r-- | _test/tests/inc/common_basicinfo.test.php | 64 | ||||
-rw-r--r-- | _test/tests/inc/common_mediainfo.test.php | 49 |
2 files changed, 113 insertions, 0 deletions
diff --git a/_test/tests/inc/common_basicinfo.test.php b/_test/tests/inc/common_basicinfo.test.php new file mode 100644 index 000000000..0369474c9 --- /dev/null +++ b/_test/tests/inc/common_basicinfo.test.php @@ -0,0 +1,64 @@ +<?php + +class common_infofunctions_test extends DokuWikiTest { + + function setup(){ + parent::setup(); + + global $USERINFO; + $USERINFO = array( + 'pass' => '179ad45c6ce2cb97cf1029e212046e81', + 'name' => 'Arthur Dent', + 'mail' => 'arthur@example.com', + 'grps' => array ('admin','user'), + ); + $_SERVER['REMOTE_USER'] = 'testuser'; + $_SERVER['REMOTE_ADDR'] = '1.2.3.4'; + } + + function _get_info() { + global $USERINFO; + $info = array (
+ 'isadmin' => true,
+ 'ismanager' => true, + 'userinfo' => $USERINFO,
+ 'perm' => 255,
+ 'namespace' => false,
+ 'ismobile' => false, + 'client' => 'testuser', + ); + + return $info; + } + + /** + * Its important to have the correct set of keys. + * Other functions provide the values + */ + function test_basicinfo(){ + // test with REMOTE_USER set and the user an admin user + $info = $this->_get_info(); + $this->assertEquals(basicinfo($ID,true),$info); + + // with $httpclient parameter set to false + unset($info['ismobile']); + $this->assertEquals(basicinfo($ID,false),$info); + + // with anonymous user + unset($_SERVER['REMOTE_USER']); + global $USERINFO; $USERINFO = array(); + + $info = array( + 'isadmin' => false, + 'ismanager' => false, + 'perm' => 8, + 'namespace' => false, + 'ismobile' => false, + 'client' => '1.2.3.4', + ); + $this->assertEquals(basicinfo($ID,true),$info); + } + +} + +//Setup VIM: ex: et ts=4 : diff --git a/_test/tests/inc/common_mediainfo.test.php b/_test/tests/inc/common_mediainfo.test.php new file mode 100644 index 000000000..0e67fbcd9 --- /dev/null +++ b/_test/tests/inc/common_mediainfo.test.php @@ -0,0 +1,49 @@ +<?php + +class common_basicinfo_test extends DokuWikiTest { + + function setup(){ + parent::setup(); + + global $USERINFO; + $USERINFO = array( + 'pass' => '179ad45c6ce2cb97cf1029e212046e81', + 'name' => 'Arthur Dent', + 'mail' => 'arthur@example.com', + 'grps' => array ('admin','user'), + ); + $_SERVER['REMOTE_USER'] = 'testuser'; + $_SERVER['REMOTE_ADDR'] = '1.2.3.4'; + } + + function _get_info() { + global $USERINFO; + $info = array (
+ 'isadmin' => true,
+ 'ismanager' => true, + 'userinfo' => $USERINFO,
+ 'perm' => 255,
+ 'namespace' => false,
+ 'ismobile' => false, + 'client' => 'testuser', + ); + + return $info; + } + + /** + * We're interested in the extra keys for $INFO when its a media request + */ + function test_mediainfo(){ + global $NS, $IMG; + $NS = ''; + $IMG = 'testimage.png'; + + $info = $this->_get_info(); + $info['image'] = 'testimage.png'; + + $this->assertEquals(mediainfo(),$info); + } +} + +//Setup VIM: ex: et ts=4 : |