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