1abc3ac64SMichael Große<?php 2abc3ac64SMichael Große/** 3abc3ac64SMichael Große * Unittests for the mail functionality of the publish plugin 4abc3ac64SMichael Große * 5abc3ac64SMichael Große * @group plugin_publish 6abc3ac64SMichael Große * @group plugin_publish_unittests 7abc3ac64SMichael Große * @group plugins 8abc3ac64SMichael Große * @group unittests 9abc3ac64SMichael Große * @author Michael Große <grosse@cosmocode.de> 10abc3ac64SMichael Große */ 11abc3ac64SMichael Großeclass publish_mail_unit_test extends DokuWikiTest { 12abc3ac64SMichael Große 13abc3ac64SMichael Große protected $pluginsEnabled = array('publish'); 14abc3ac64SMichael Große 15abc3ac64SMichael Große /** 16abc3ac64SMichael Große * @covers action_plugin_publish_mail::difflink 17abc3ac64SMichael Große */ 18abc3ac64SMichael Große function test_difflink () { 19abc3ac64SMichael Große global $ID; 20abc3ac64SMichael Große $ID = 'wiki:syntax'; 211d7b4c34SMichael Große 221d7b4c34SMichael Große /** @var helper_plugin_publish $helper*/ 231d7b4c34SMichael Große $helper = plugin_load('helper','publish'); 241d7b4c34SMichael Große $actual_difflink = $helper->getDifflink('wiki:syntax','1','2'); 25efec8cf1SMichael Große $expected_difflink = 'http://wiki.example.com/./doku.php?id=wiki:syntax&do=diff&rev2[0]=1&rev2[1]=2&difftype=sidebyside'; 26efec8cf1SMichael Große $this->assertSame($expected_difflink,$actual_difflink); 27abc3ac64SMichael Große } 28abc3ac64SMichael Große 29abc3ac64SMichael Große /** 30f31c6595SMichael Große * @covers action_plugin_publish_mail::revlink 31abc3ac64SMichael Große */ 32abc3ac64SMichael Große function test_apprejlink () { 33abc3ac64SMichael Große global $ID; 34abc3ac64SMichael Große $ID = 'wiki:syntax'; 35abc3ac64SMichael Große $mail = new action_plugin_publish_mail; 36f31c6595SMichael Große $actual_apprejlink = $mail->revlink('wiki:syntax','1'); 371d7b4c34SMichael Große $expected_apprejlink = 'http://wiki.example.com/./doku.php?id=wiki:syntax&rev=1'; //this stray dot comes from an unclean test-setup 38abc3ac64SMichael Große $this->assertSame($expected_apprejlink, $actual_apprejlink); 39abc3ac64SMichael Große } 4039e87974SMichael Große 4139e87974SMichael Große /** 42bc4555caSMichael Große * @covers action_plugin_publish_mail::create_mail_body 4339e87974SMichael Große * @group slow 4439e87974SMichael Große */ 4539e87974SMichael Große function test_change_mail_body () { 4639e87974SMichael Große global $ID; 4739e87974SMichael Große $ID = 'start'; 4839e87974SMichael Große global $USERINFO; 4939e87974SMichael Große $_SERVER['REMOTE_USER'] = 'john'; 5039e87974SMichael Große $USERINFO['name'] = 'John Smith'; 5139e87974SMichael Große saveWikiText('start', 'start first', 'foobar'); 5239e87974SMichael Große $oldrevision = pageinfo(); 5339e87974SMichael Große $oldrevision = $oldrevision['lastmod']; 5439e87974SMichael Große sleep(1); 5539e87974SMichael Große saveWikiText('start', 'start second', 'foobar'); 5639e87974SMichael Große $newrevision = pageinfo(); 5739e87974SMichael Große $newrevision = $newrevision['lastmod']; 5839e87974SMichael Große 59*c447490bSMichael Große $expected_mail_body = 60*c447490bSMichael Große'There is a new suggestion in your DokuWiki. Here are the details: 6139e87974SMichael Große 62*c447490bSMichael GroßeDate : @DATE@ 63*c447490bSMichael GroßeBrowser : @BROWSER@ 64*c447490bSMichael GroßeIP-Address : @IPADDRESS@ 65*c447490bSMichael GroßeHostname : @HOSTNAME@ 66*c447490bSMichael GroßePrevious Revision: http://wiki.example.com/./doku.php?id=start&rev=' . $oldrevision . ' 67*c447490bSMichael GroßeNew Revision : http://wiki.example.com/./doku.php?id=start&rev=' . $newrevision . ' 68*c447490bSMichael GroßeEdit Summary : foobar 69*c447490bSMichael GroßeUser : @USER@ 7039e87974SMichael Große 71*c447490bSMichael Großehttp://wiki.example.com/./doku.php?id=start&do=diff&rev2[0]=' . $oldrevision . '&rev2[1]=' . $newrevision . '&difftype=sidebyside 72*c447490bSMichael Große 73*c447490bSMichael Große 74*c447490bSMichael GroßePlease review the changes and approve the revision at http://wiki.example.com/./doku.php?id=start&rev=' . $newrevision . ' or give feedback to @USER@. 7539e87974SMichael Große 7639e87974SMichael Große-- 7739e87974SMichael GroßeThis mail was generated by DokuWiki at 78*c447490bSMichael Großehttp://wiki.example.com/./ 79*c447490bSMichael Große'; 8039e87974SMichael Große 8139e87974SMichael Große 8239e87974SMichael Große $mail = new action_plugin_publish_mail; 8339e87974SMichael Große $data = pageinfo(); 84e6206222SMichael Große $actual_mail_body = $mail->create_mail_body('change'); 85bc4555caSMichael Große 86bc4555caSMichael Große $this->assertSame($expected_mail_body, $actual_mail_body); 87bc4555caSMichael Große 88bc4555caSMichael Große } 89bc4555caSMichael Große 90bc4555caSMichael Große 91bc4555caSMichael Große /** 92bc4555caSMichael Große * @covers action_plugin_publish_mail::create_mail_body 93bc4555caSMichael Große */ 94bc4555caSMichael Große function test_approve_mail_body () { 95bc4555caSMichael Große global $ID; 96bc4555caSMichael Große $ID = 'start'; 97bc4555caSMichael Große global $USERINFO; 98bc4555caSMichael Große $_SERVER['REMOTE_USER'] = 'john'; 99bc4555caSMichael Große $USERINFO['name'] = 'John Smith'; 100bc4555caSMichael Große saveWikiText('start', 'start first', 'foobar'); 101bc4555caSMichael Große $revision = pageinfo(); 102bc4555caSMichael Große $revision = $revision['lastmod']; 103bc4555caSMichael Große 104bc4555caSMichael Große $expected_mail_body = 'Hi John Smith! 105bc4555caSMichael GroßeYour suggestion for My Test Wiki at http://wiki.example.com/./ 106bc4555caSMichael Große 107bc4555caSMichael GroßeURL: http://wiki.example.com/./doku.php?id=start&rev=' . $revision . ' 108bc4555caSMichael Große 109bc4555caSMichael Großeis approved. 110bc4555caSMichael Große 111bc4555caSMichael Große-- 112bc4555caSMichael GroßeThis mail was generated by DokuWiki at 113*c447490bSMichael Großehttp://wiki.example.com/./ 114*c447490bSMichael Große'; 115bc4555caSMichael Große 116bc4555caSMichael Große 117bc4555caSMichael Große $mail = new action_plugin_publish_mail; 118bc4555caSMichael Große $data = pageinfo(); 119e6206222SMichael Große $actual_mail_body = $mail->create_mail_body('approve'); 12039e87974SMichael Große 12139e87974SMichael Große $this->assertSame($expected_mail_body, $actual_mail_body); 12239e87974SMichael Große 12339e87974SMichael Große } 124abc3ac64SMichael Große} 125