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