xref: /plugin/publish/_test/mail.test.php (revision a94f9b5fc3253bc3b4b600426e90c2935733c1e2) !
1abc3ac64SMichael Große<?php
2abc3ac64SMichael Große/**
3abc3ac64SMichael Große * General tests for the publish plugin
4abc3ac64SMichael Große *
5abc3ac64SMichael Große * @group plugin_publish
6abc3ac64SMichael Große * @group plugin_publish_integration
7abc3ac64SMichael Große * @group plugins
8abc3ac64SMichael Große * @group integrationtests
9abc3ac64SMichael Große * @author Michael Große <grosse@cosmocode.de>
10abc3ac64SMichael Große */
11abc3ac64SMichael Großeclass publish_mail_test extends DokuWikiTest {
12abc3ac64SMichael Große
13abc3ac64SMichael Große    protected $pluginsEnabled = array('publish');
14abc3ac64SMichael Große
15*a94f9b5fSAnna Dabrowska    public function setUp(): void
16*a94f9b5fSAnna Dabrowska    {
17abc3ac64SMichael Große        parent::setUp();
18abc3ac64SMichael Große
19abc3ac64SMichael Große        global $USERINFO;
20abc3ac64SMichael Große        $USERINFO = array(
21abc3ac64SMichael Große            'pass' => '179ad45c6ce2cb97cf1029e212046e81',
22abc3ac64SMichael Große            'name' => 'Arthur Dent',
23abc3ac64SMichael Große            'mail' => 'arthur@example.com',
24abc3ac64SMichael Große            'grps' => array ('admin','user'),
25abc3ac64SMichael Große        );
26abc3ac64SMichael Große
27abc3ac64SMichael Große        global $default_server_vars;
28abc3ac64SMichael Große        $default_server_vars['REMOTE_USER'] = 'testuser'; //Hack until Issue splitbrain/dokuwiki#1099 is fixed
29abc3ac64SMichael Große        $_SERVER['REMOTE_USER'] = 'testuser';
30abc3ac64SMichael Große
31abc3ac64SMichael Große        global $conf;
32abc3ac64SMichael Große        $conf['superuser'] = '@admin';
33abc3ac64SMichael Große    }
34abc3ac64SMichael Große
35abc3ac64SMichael Große    /**
36abc3ac64SMichael Große     * Blackbox integration test of action_plugin_publish_mail::getLastApproved
37abc3ac64SMichael Große     *
38abc3ac64SMichael Große     * @coversNothing
39abc3ac64SMichael Große     */
40abc3ac64SMichael Große    public function test_getLastApproved () {
41abc3ac64SMichael Große        global $ID;
42abc3ac64SMichael Große        $ID = 'foo';
43abc3ac64SMichael Große        saveWikiText('foo', 'bar old', 'foobar');
44abc3ac64SMichael Große        saveWikiText('foo', 'bar approved', 'foobar');
45abc3ac64SMichael Große        $data = pageinfo();
46abc3ac64SMichael Große        $expected_revision = $data['currentrev'];
47abc3ac64SMichael Große
48abc3ac64SMichael Große        //Make sure we have the rights to actully approve a revision
49abc3ac64SMichael Große        $this->assertSame(255,auth_quickaclcheck('foo'));
50abc3ac64SMichael Große
51abc3ac64SMichael Große        $request = new TestRequest();
52abc3ac64SMichael Große        $request->get(array(), '/doku.php?id=foo&publish_approve');
53abc3ac64SMichael Große
54abc3ac64SMichael Große        saveWikiText('foo', 'bar new', 'foobar');
55abc3ac64SMichael Große
564f5c41dbSMichael Große        /** @var helper_plugin_publish $helper */
571d7b4c34SMichael Große        $helper = plugin_load('helper','publish');
581d7b4c34SMichael Große        $actual_lastapproved_helper = $helper->getLatestApprovedRevision($ID);
59abc3ac64SMichael Große
601d7b4c34SMichael Große        $this->assertSame($expected_revision, $actual_lastapproved_helper);
61abc3ac64SMichael Große    }
62abc3ac64SMichael Große
63abc3ac64SMichael Große
64abc3ac64SMichael Große}
65