ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMailTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once 'Services/Mail/classes/class.ilMimeMail.php';
5 
15 {
16  protected $backupGlobals = false;
17 
18  protected function setUp()
19  {
20  include_once 'Services/PHPUnit/classes/class.ilUnitUtil.php';
22  }
23 
24  public function testEmpty()
25  {
26  $this->assertEquals('foo', 'foo');
27  }
28 
29  public function testIdentifiedUserIsSender()
30  {
31  global $ilUser;
32 
33  $mail = new ilMail($ilUser->getId());
34  $sender = $mail->getMimeMailSender();
35 
36  $this->assertEquals($sender, ilMimeMail::_mimeEncode($ilUser->getFullname()).'<'.$ilUser->getEmail().'>');
37  }
38 
40  {
41  global $ilSetting;
42 
43  $tmp = $ilSetting->get('mail_external_sender_noreply');
44 
45  $ilSetting->set('mail_external_sender_noreply', '');
46 
47  $mail = new ilMail(ANONYMOUS_USER_ID);
48  $sender = $mail->getMimeMailSender();
49 
50  $ilSetting->set('mail_external_sender_noreply', $tmp);
51 
52  $this->assertEquals($sender, ilMimeMail::_mimeEncode(ilMail::_getAnonymousName()).'<noreply@'.$_SERVER['SERVER_NAME'].'>');
53  }
54 
56  {
57  global $ilSetting;
58 
59  $tmp = $ilSetting->get('mail_external_sender_noreply');
60 
61  $ilSetting->set('mail_external_sender_noreply', 'host.de');
62 
63  $mail = new ilMail(ANONYMOUS_USER_ID);
64  $sender = $mail->getMimeMailSender();
65 
66  $ilSetting->set('mail_external_sender_noreply', $tmp);
67 
68  $this->assertEquals($sender, ilMimeMail::_mimeEncode(ilMail::_getAnonymousName()).'<noreply@host.de>');
69  }
70 
72  {
73  global $ilSetting;
74 
75  $tmp = $ilSetting->get('mail_external_sender_noreply');
76 
77  $ilSetting->set('mail_external_sender_noreply', 'doNotReply@host.de');
78 
79  $mail = new ilMail(ANONYMOUS_USER_ID);
80  $sender = $mail->getMimeMailSender();
81 
82  $ilSetting->set('mail_external_sender_noreply', $tmp);
83 
84  $this->assertEquals($sender, ilMimeMail::_mimeEncode(ilMail::_getAnonymousName()).'<doNotReply@host.de>');
85  }
86 }
87 ?>