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 /** 301d7b4c34SMichael Große * @covers action_plugin_publish_mail::apprejlink 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; 36abc3ac64SMichael Große $actual_apprejlink = $mail->apprejlink('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 } 40*39e87974SMichael Große 41*39e87974SMichael Große /** 42*39e87974SMichael Große * @covers action_plugin_publish_mail::create_approve_mail_body 43*39e87974SMichael Große * @group slow 44*39e87974SMichael Große */ 45*39e87974SMichael Große function test_change_mail_body () { 46*39e87974SMichael Große global $ID; 47*39e87974SMichael Große $ID = 'start'; 48*39e87974SMichael Große global $USERINFO; 49*39e87974SMichael Große $_SERVER['REMOTE_USER'] = 'john'; 50*39e87974SMichael Große $USERINFO['name'] = 'John Smith'; 51*39e87974SMichael Große saveWikiText('start', 'start first', 'foobar'); 52*39e87974SMichael Große $oldrevision = pageinfo(); 53*39e87974SMichael Große $oldrevision = $oldrevision['lastmod']; 54*39e87974SMichael Große sleep(1); 55*39e87974SMichael Große saveWikiText('start', 'start second', 'foobar'); 56*39e87974SMichael Große $newrevision = pageinfo(); 57*39e87974SMichael Große $newrevision = $newrevision['lastmod']; 58*39e87974SMichael Große 59*39e87974SMichael Große $expected_mail_body = 'Hi John Smith! 60*39e87974SMichael GroßeA new suggestion for My Test Wiki at http://wiki.example.com/./ 61*39e87974SMichael Große 62*39e87974SMichael GroßeView and approve: http://wiki.example.com/./doku.php?id=start&rev=' . $newrevision . ' 63*39e87974SMichael Große 64*39e87974SMichael GroßeChanges from previous version: http://wiki.example.com/./doku.php?id=start&do=diff&rev2[0]=' . $oldrevision . '&rev2[1]=' . $newrevision . '&difftype=sidebyside 65*39e87974SMichael Große 66*39e87974SMichael Große-- 67*39e87974SMichael GroßeThis mail was generated by DokuWiki at 68*39e87974SMichael Großehttp://wiki.example.com/./'; 69*39e87974SMichael Große 70*39e87974SMichael Große 71*39e87974SMichael Große $mail = new action_plugin_publish_mail; 72*39e87974SMichael Große $data = pageinfo(); 73*39e87974SMichael Große $actual_mail_body = $mail->create_change_mail_body('start',$data); 74*39e87974SMichael Große 75*39e87974SMichael Große $this->assertSame($expected_mail_body, $actual_mail_body); 76*39e87974SMichael Große 77*39e87974SMichael Große } 78abc3ac64SMichael Große} 79