xref: /dokuwiki/_test/tests/inc/common_basicinfo.test.php (revision 7f081821c51e704c2720b993ca5364fa5e7e3663)
1<?php
2
3class common_infofunctions_test extends DokuWikiTest {
4
5    function setup(){
6        parent::setup();
7
8        global $USERINFO;
9        $USERINFO = array(
10           'pass' => '179ad45c6ce2cb97cf1029e212046e81',
11           'name' => 'Arthur Dent',
12           'mail' => 'arthur@example.com',
13           'grps' => array ('admin','user'),
14        );
15        $_SERVER['REMOTE_USER'] = 'testuser';
16        $_SERVER['REMOTE_ADDR'] = '1.2.3.4';
17    }
18
19    function _get_info() {
20        global $USERINFO;
21        $info = array (
22          'isadmin' => true,
23          'ismanager' => true,
24          'userinfo' => $USERINFO,
25          'perm' => 255,
26          'namespace' => false,
27          'ismobile' => false,
28          'client' => 'testuser',
29        );
30
31        return $info;
32    }
33
34    /**
35     * Its important to have the correct set of keys.
36     * Other functions provide the values
37     */
38    function test_basicinfo(){
39        // test with REMOTE_USER set and the user an admin user
40        $info = $this->_get_info();
41        $this->assertEquals(basicinfo($ID,true),$info);
42
43        // with $httpclient parameter set to false
44        unset($info['ismobile']);
45        $this->assertEquals(basicinfo($ID,false),$info);
46
47        // with anonymous user
48        unset($_SERVER['REMOTE_USER']);
49        global $USERINFO; $USERINFO = array();
50
51        $info = array(
52          'isadmin' => false,
53          'ismanager' => false,
54          'perm' => 8,
55          'namespace' => false,
56          'ismobile' => false,
57          'client' => '1.2.3.4',
58        );
59        $this->assertEquals(basicinfo($ID,true),$info);
60    }
61
62}
63
64//Setup VIM: ex: et ts=4 :
65