1<?php
2
3class common_infofunctions_test extends DokuWikiTest {
4
5    function setup() : void {
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        global $ID;
40        // test with REMOTE_USER set and the user an admin user
41        $info = $this->_get_info();
42        $this->assertEquals(basicinfo($ID,true),$info);
43
44        // with $httpclient parameter set to false
45        unset($info['ismobile']);
46        $this->assertEquals(basicinfo($ID,false),$info);
47
48        // with anonymous user
49        unset($_SERVER['REMOTE_USER']);
50        global $USERINFO; $USERINFO = array();
51
52        $info = array(
53          'isadmin' => false,
54          'ismanager' => false,
55          'perm' => 8,
56          'namespace' => false,
57          'ismobile' => false,
58          'client' => '1.2.3.4',
59        );
60        $this->assertEquals(basicinfo($ID,true),$info);
61    }
62
63}
64
65//Setup VIM: ex: et ts=4 :
66