xref: /plugin/publish/_test/publish.test.php (revision 6249ebcd3918581ccecc37e193baf64cd2a507a1)
1*6249ebcdSMichael Große<?php
2*6249ebcdSMichael Große
3*6249ebcdSMichael Große/**
4*6249ebcdSMichael Große * General tests for the publish plugin
5*6249ebcdSMichael Große *
6*6249ebcdSMichael Große * @group plugin_publish
7*6249ebcdSMichael Große * @group plugins
8*6249ebcdSMichael Große */
9*6249ebcdSMichael Großeclass approvel_test extends DokuWikiTest {
10*6249ebcdSMichael Große
11*6249ebcdSMichael Große    public function setUp(){
12*6249ebcdSMichael Große        parent::setUp();
13*6249ebcdSMichael Große
14*6249ebcdSMichael Große        global $USERINFO;
15*6249ebcdSMichael Große        $USERINFO = array(
16*6249ebcdSMichael Große           'pass' => '179ad45c6ce2cb97cf1029e212046e81',
17*6249ebcdSMichael Große           'name' => 'Arthur Dent',
18*6249ebcdSMichael Große           'mail' => 'arthur@example.com',
19*6249ebcdSMichael Große           'grps' => array ('admin','user'),
20*6249ebcdSMichael Große        );
21*6249ebcdSMichael Große        $_SERVER['REMOTE_USER'] = 'testuser';
22*6249ebcdSMichael Große        $_SERVER['REMOTE_ADDR'] = '1.2.3.4';
23*6249ebcdSMichael Große
24*6249ebcdSMichael Große        global $INFO;
25*6249ebcdSMichael Große        $INFO = pageinfo();
26*6249ebcdSMichael Große    }
27*6249ebcdSMichael Große
28*6249ebcdSMichael Große    protected $pluginsEnabled = array('publish');
29*6249ebcdSMichael Große
30*6249ebcdSMichael Große    public function test_unaprroved_banner_exists() {
31*6249ebcdSMichael Große        saveWikiText('foo', 'bar', 'foobar');
32*6249ebcdSMichael Große        $request = new TestRequest();
33*6249ebcdSMichael Große        $response = $request->get(array('id' => 'foo'), '/doku.php?id=foo');
34*6249ebcdSMichael Große        $this->assertTrue(
35*6249ebcdSMichael Große            strpos($response->getContent(), '<div class="approval approved_no">') !== false,
36*6249ebcdSMichael Große            'The "not approved banner" is missing on a page which has not yet been aprroved with standard config.'
37*6249ebcdSMichael Große        );
38*6249ebcdSMichael Große
39*6249ebcdSMichael Große    }
40*6249ebcdSMichael Große
41*6249ebcdSMichael Große    public function test_aprroval_succesful() {
42*6249ebcdSMichael Große        global $USERINFO;
43*6249ebcdSMichael Große        global $INFO;
44*6249ebcdSMichael Große        saveWikiText('foo', 'bar', 'foobar');
45*6249ebcdSMichael Große        $request = new TestRequest();
46*6249ebcdSMichael Große        $_SERVER['REMOTE_USER'] = 'testuser';
47*6249ebcdSMichael Große        $_SERVER['REMOTE_ADDR'] = '1.2.3.4';
48*6249ebcdSMichael Große        $response = $request->post(array('id' => 'foo'), '/doku.php?id=foo&publish_approve=1');
49*6249ebcdSMichael Große        print_r($INFO);
50*6249ebcdSMichael Große        print_r($response->getContent());
51*6249ebcdSMichael Große        print_r($USERINFO);
52*6249ebcdSMichael Große        print_r($_SERVER['REMOTE_USER']);
53*6249ebcdSMichael Große
54*6249ebcdSMichael Große        $this->assertTrue(
55*6249ebcdSMichael Große            strpos($response->getContent(), '<div class="approval approved_yes">') !== false,
56*6249ebcdSMichael Große            'Approving a page failed with standard options.'
57*6249ebcdSMichael Große        );
58*6249ebcdSMichael Große
59*6249ebcdSMichael Große    }
60*6249ebcdSMichael Große
61*6249ebcdSMichael Große    public function test_no_aprroved_banner() {
62*6249ebcdSMichael Große        $conf['plugin']['publish']['hide approved banner'] = '1';
63*6249ebcdSMichael Große        saveWikiText('foo', 'bar', 'foobar');
64*6249ebcdSMichael Große        $request = new TestRequest();
65*6249ebcdSMichael Große        $response = $request->get(array('id' => 'foo'), '/doku.php?id=foo&publish_approve=1');
66*6249ebcdSMichael Große        $this->assertTrue(
67*6249ebcdSMichael Große            strpos($response->getContent(), '<div class="approval') === false,
68*6249ebcdSMichael Große            'The approved banner is still showing even so it is supposed not to show.'
69*6249ebcdSMichael Große        );
70*6249ebcdSMichael Große
71*6249ebcdSMichael Große    }
72*6249ebcdSMichael Große}
73