1<?php
2
3/**
4 * General tests for the publish plugin
5 *
6 * @group plugin_publish_integration
7 * @group plugin_publish
8 * @group plugins
9 * @group integrationtests
10 * @author Michael Große <grosse@cosmocode.de>
11 */
12class approvel_test extends DokuWikiTest {
13
14    protected $pluginsEnabled = array('publish');
15
16    public function setUp(){
17        parent::setUp();
18
19        global $USERINFO;
20        $USERINFO = array(
21           'pass' => '179ad45c6ce2cb97cf1029e212046e81',
22           'name' => 'Arthur Dent',
23           'mail' => 'arthur@example.com',
24           'grps' => array ('admin','user'),
25        );
26
27        global $default_server_vars;
28        $default_server_vars['REMOTE_USER'] = 'testuser'; //Hack until Issue splitbrain/dokuwiki#1099 is fixed
29
30        $_SERVER['REMOTE_USER'] = 'testuser';
31
32        global $conf;
33        global $AUTH_ACL;
34        $conf['useacl']    = 1;
35        $conf['superuser'] = '@admin';
36        $AUTH_ACL = array(
37            '*                     @ALL        4',
38            '*                     @admin     16',);
39    }
40
41    /**
42     * @coversNothing
43     */
44    public function test_unaprroved_banner_exists() {
45        saveWikiText('foo', 'bar', 'foobar');
46        $request = new TestRequest();
47        $response = $request->get(array('id' => 'foo'), '/doku.php?id=foo');
48        $this->assertTrue(
49            strpos($response->getContent(), '<div class="approval approved_no">') !== false,
50            'The "not approved banner" is missing on a page which has not yet been aprroved with standard config.'
51        );
52
53    }
54
55    /**
56     * @coversNothing
57     */
58    public function test_aprroval_succesful() {
59        saveWikiText('foo', 'bar', 'foobar');
60        $request = new TestRequest();
61        $response = $request->get(array(), '/doku.php?id=foo&publish_approve=1');
62        $this->assertTrue(
63            strpos($response->getContent(), '<div class="approval approved_yes">') !== false,
64            'Approving a page failed with standard options.'
65        );
66
67    }
68
69    /**
70     * @coversNothing
71     */
72    public function test_no_aprroved_banner() {
73        global $conf;
74        $conf['plugin']['publish']['hide_approved_banner'] = 1;
75        saveWikiText('foo', 'bar', 'foobar');
76
77        $request = new TestRequest();
78        $response = $request->get(array(), '/doku.php?id=foo&publish_approve=1');
79
80        $this->assertTrue(
81            strpos($response->getContent(), '<div class="approval') === false,
82            'The approved banner is still showing even so it is supposed not to show.'
83        );
84
85    }
86}
87