16249ebcdSMichael Große<?php 26249ebcdSMichael Große 36249ebcdSMichael Große/** 46249ebcdSMichael Große * General tests for the publish plugin 56249ebcdSMichael Große * 6abc3ac64SMichael Große * @group plugin_publish_integration 76249ebcdSMichael Große * @group plugin_publish 86249ebcdSMichael Große * @group plugins 9abc3ac64SMichael Große * @group integrationtests 10abc3ac64SMichael Große * @author Michael Große <grosse@cosmocode.de> 116249ebcdSMichael Große */ 126249ebcdSMichael Großeclass approvel_test extends DokuWikiTest { 136249ebcdSMichael Große 14abc3ac64SMichael Große protected $pluginsEnabled = array('publish'); 15abc3ac64SMichael Große 16*a94f9b5fSAnna Dabrowska public function setUp(): void 17*a94f9b5fSAnna Dabrowska { 186249ebcdSMichael Große parent::setUp(); 196249ebcdSMichael Große 206249ebcdSMichael Große global $USERINFO; 216249ebcdSMichael Große $USERINFO = array( 226249ebcdSMichael Große 'pass' => '179ad45c6ce2cb97cf1029e212046e81', 236249ebcdSMichael Große 'name' => 'Arthur Dent', 246249ebcdSMichael Große 'mail' => 'arthur@example.com', 256249ebcdSMichael Große 'grps' => array ('admin','user'), 266249ebcdSMichael Große ); 276249ebcdSMichael Große 28abc3ac64SMichael Große global $default_server_vars; 29abc3ac64SMichael Große $default_server_vars['REMOTE_USER'] = 'testuser'; //Hack until Issue splitbrain/dokuwiki#1099 is fixed 30abc3ac64SMichael Große 31abc3ac64SMichael Große $_SERVER['REMOTE_USER'] = 'testuser'; 32abc3ac64SMichael Große 33abc3ac64SMichael Große global $conf; 34abc3ac64SMichael Große global $AUTH_ACL; 35abc3ac64SMichael Große $conf['useacl'] = 1; 36abc3ac64SMichael Große $conf['superuser'] = '@admin'; 37abc3ac64SMichael Große $AUTH_ACL = array( 38abc3ac64SMichael Große '* @ALL 4', 39abc3ac64SMichael Große '* @admin 16',); 406249ebcdSMichael Große } 416249ebcdSMichael Große 42abc3ac64SMichael Große /** 43abc3ac64SMichael Große * @coversNothing 44abc3ac64SMichael Große */ 456249ebcdSMichael Große public function test_unaprroved_banner_exists() { 466249ebcdSMichael Große saveWikiText('foo', 'bar', 'foobar'); 476249ebcdSMichael Große $request = new TestRequest(); 486249ebcdSMichael Große $response = $request->get(array('id' => 'foo'), '/doku.php?id=foo'); 496249ebcdSMichael Große $this->assertTrue( 506249ebcdSMichael Große strpos($response->getContent(), '<div class="approval approved_no">') !== false, 516249ebcdSMichael Große 'The "not approved banner" is missing on a page which has not yet been aprroved with standard config.' 526249ebcdSMichael Große ); 536249ebcdSMichael Große 546249ebcdSMichael Große } 556249ebcdSMichael Große 56abc3ac64SMichael Große /** 57abc3ac64SMichael Große * @coversNothing 58abc3ac64SMichael Große */ 596249ebcdSMichael Große public function test_aprroval_succesful() { 606249ebcdSMichael Große saveWikiText('foo', 'bar', 'foobar'); 616249ebcdSMichael Große $request = new TestRequest(); 62abc3ac64SMichael Große $response = $request->get(array(), '/doku.php?id=foo&publish_approve=1'); 636249ebcdSMichael Große $this->assertTrue( 646249ebcdSMichael Große strpos($response->getContent(), '<div class="approval approved_yes">') !== false, 656249ebcdSMichael Große 'Approving a page failed with standard options.' 666249ebcdSMichael Große ); 676249ebcdSMichael Große 686249ebcdSMichael Große } 696249ebcdSMichael Große 70abc3ac64SMichael Große /** 71abc3ac64SMichael Große * @coversNothing 72abc3ac64SMichael Große */ 736249ebcdSMichael Große public function test_no_aprroved_banner() { 74abc3ac64SMichael Große global $conf; 75abc3ac64SMichael Große $conf['plugin']['publish']['hide_approved_banner'] = 1; 766249ebcdSMichael Große saveWikiText('foo', 'bar', 'foobar'); 77abc3ac64SMichael Große 786249ebcdSMichael Große $request = new TestRequest(); 79abc3ac64SMichael Große $response = $request->get(array(), '/doku.php?id=foo&publish_approve=1'); 80abc3ac64SMichael Große 816249ebcdSMichael Große $this->assertTrue( 826249ebcdSMichael Große strpos($response->getContent(), '<div class="approval') === false, 836249ebcdSMichael Große 'The approved banner is still showing even so it is supposed not to show.' 846249ebcdSMichael Große ); 856249ebcdSMichael Große 866249ebcdSMichael Große } 876249ebcdSMichael Große} 88