diff options
author | Klap-in <klapinklapin@gmail.com> | 2013-07-21 23:10:32 +0200 |
---|---|---|
committer | Klap-in <klapinklapin@gmail.com> | 2013-07-21 23:10:32 +0200 |
commit | b1ffadaa6963bbf83e61917c31e04c04c421ce9e (patch) | |
tree | f9a1391d2ee6536473b1672e249c1b11a67a5b0e /_test | |
parent | fa3ed26bfbafa4d05ec77a799259d4a46baadd9a (diff) | |
parent | fbd8067eeeb9f424981aad8b283e17f734c738c3 (diff) | |
download | rpg-b1ffadaa6963bbf83e61917c31e04c04c421ce9e.tar.gz rpg-b1ffadaa6963bbf83e61917c31e04c04c421ce9e.tar.bz2 |
Merge remote-tracking branch 'origin/master' into fetchimagetokexternal
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/common_basicinfo.test.php | 64 | ||||
-rw-r--r-- | _test/tests/inc/common_mediainfo.test.php | 49 | ||||
-rw-r--r-- | _test/tests/inc/media_isexternal.test.php | 22 |
3 files changed, 135 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 : diff --git a/_test/tests/inc/media_isexternal.test.php b/_test/tests/inc/media_isexternal.test.php new file mode 100644 index 000000000..cf5f793e4 --- /dev/null +++ b/_test/tests/inc/media_isexternal.test.php @@ -0,0 +1,22 @@ +<?php + +class media_isexternal_test extends DokuWikiTest { + + + public function test_external(){ + $this->assertTrue(media_isexternal('http://www.example.com/foo.png')); + $this->assertTrue(media_isexternal('https://www.example.com/foo.png')); + $this->assertTrue(media_isexternal('ftp://www.example.com/foo.png')); + $this->assertTrue(media_isexternal('hTTp://www.example.com/foo.png')); + $this->assertTrue(media_isexternal('hTTps://www.example.com/foo.png')); + $this->assertTrue(media_isexternal('Ftp://www.example.com/foo.png')); + } + + public function test_internal(){ + $this->assertFalse(media_isexternal('wiki:logo.png')); + $this->assertFalse(media_isexternal('private:logo.png')); + $this->assertFalse(media_isexternal('ftp:private:logo.png')); + + } + +}
\ No newline at end of file |