1<?php
2/**
3 * @group plugin_sneakyindexfix
4 * @group plugins
5 */
6class plugin_sneakyindexfix_main_test extends DokuWikiTest {
7    protected $oldAuth;
8    protected $oldAuthAcl;
9    protected $oldConf;
10
11    function setUp() {
12        global $auth;
13        global $AUTH_ACL;
14        global $USERINFO;
15        global $conf;
16
17        $this->oldAuth    = $auth;
18        $this->oldAuthAcl = $AUTH_ACL;
19        $this->oldConf    = $conf;
20
21        $this->pluginsEnabled[] = 'sneakyindexfix';
22
23        parent::setUp();
24
25        $_SERVER['REMOTE_USER'] = 'testuser';
26        $USERINFO['grps'] = array('foo','bar');
27        $conf['useacl']    = 1;
28        $conf['superuser'] = '';
29    }
30
31    function tearDown() {
32        global $conf;
33        global $AUTH_ACL;
34        global $auth;
35
36        $auth     = $this->oldAuth;
37//         $AUTH_ACL = $this->oldAuthAcl;
38//         $conf     = $this->conf;
39    }
40
41    function revertACL() {
42        global $AUTH_ACL;
43        $AUTH_ACL = $this->oldAuthAcl;
44    }
45
46    public function test_sneaky_index_off() {
47        $conf['sneaky_index']    = 0;
48
49        $AUTH_ACL[] = 'private:public:* @ALL  8';
50        $perm = auth_quickaclcheck('private:*');
51
52        $this->assertEquals(AUTH_NONE, $perm);
53    }
54
55    public function test_ns_sub_access() {
56        global $AUTH_ACL;
57        global $conf;
58
59        $conf['sneaky_index']    = 1;
60
61        $AUTH_ACL[] = 'private:public:* @ALL  8';
62        $perm = auth_quickaclcheck('private:*');
63
64        $this->assertEquals(AUTH_READ, $perm);
65
66    }
67
68    public function test_ns_page_access() {
69        global $AUTH_ACL;
70        global $conf;
71
72        $conf['sneaky_index']    = 1;
73        $AUTH_ACL[] = 'private:public:public @ALL  1';
74        $perm = auth_quickaclcheck('private:*');
75
76        $this->assertEquals(AUTH_READ, $perm);
77
78    }
79}
80