public function testMail()
{
+ $header =
+'Subject: This is a personal alarm.
+To: john@example.com
+From: john@example.com
+Auto-Submitted: auto-generated
+X-Horde-Alarm: This is a personal alarm.
+Message-ID: <%d.Horde.%s@%s>
+User-Agent: Horde Application Framework 4
+Date: %s, %d %s %s %d:%d:%d %s%d
+Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes
+MIME-Version: 1.0';
+ $body = "Action is required.\n";
+
$alarm = self::$alarm->get('personalalarm', 'john');
$alarm['methods'] = array('mail');
self::$alarm->set($alarm);
self::$alarm->notify('john', false);
- $regexp = <<<EOR
-Subject: This is a personal alarm\.
-To: john@example\.com
-From: john@example\.com
-Auto-Submitted: auto-generated
-X-Horde-Alarm: This is a personal alarm\.
-Message-ID: <\d{14}\.Horde\.\w+@\w+>
-User-Agent: Horde Application Framework 4
-Date: \w{3}, \d\d \w{3} \d{4} \d\d:\d\d:\d\d [+-]\d{4}
-Content-Type: text\/plain; charset=UTF-8; format=flowed; DelSp=Yes
-MIME-Version: 1\.0
-
-Action is required\.
-
-EOR;
- $regexp = trim(str_replace("\r\n", "\n", $regexp));
-
$last_sent = end(self::$mail->sentMessages);
- $sent_message = $last_sent['header_text'] . "\n\n" . $last_sent['body'];
- $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", $sent_message)));
+
+ $this->assertStringMatchesFormat(
+ $header,
+ trim(str_replace("\r\n", "\n", $last_sent['header_text']))
+ );
+ $this->assertEquals($body, $last_sent['body']);
self::$mail->sentMessages = array();
self::$alarm->notify('john', false);
self::$alarm->notify('john', false);
$last_sent = end(self::$mail->sentMessages);
- $sent_message = $last_sent['header_text'] . "\n\n" . $last_sent['body'];
- $this->assertRegExp('/' . $regexp . '/', trim(str_replace("\r\n", "\n", $sent_message)));
+ $this->assertStringMatchesFormat(
+ $header,
+ trim(str_replace("\r\n", "\n", $last_sent['header_text']))
+ );
+ $this->assertEquals($body, $last_sent['body']);
}
}
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s
Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
"This is\nthe body\n",
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: text/plain; charset=iso-8859-15; format=flowed; DelSp=Yes
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
"This is\nthe body\n",
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: =?iso-8859-1?b?U2No9m5lcg==?= Betreff
To: =?iso-8859-1?b?RW1wZuRuZ2Vy?= <recipient@example.com>
From: sender@example.com
Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
"H=FCbsche Umlaute\n und Leerzeichen.\n",
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: multipart/mixed; boundary="=_%s"
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
-
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
+
+ $this->assertStringMatchesFormat(
"This message is in MIME format.
--=_%s
WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5
bHRlciBEZWljaC4K
--=_%s--\n",
- $dummy->sentMessages[0]['body']
- );
- } else {
- $this->markTestSkipped();
- }
+ $dummy->sentMessages[0]['body']
+ );
$this->assertEquals(
array('recipient@example.com'),
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
"This is\nthe plain text body.",
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: text/html; charset=iso-8859-1
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
"<h1>Header Title</h1>\n<p>This is<br />the html text body.</p>",
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: multipart/alternative; boundary="=_%s"
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
-
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
+
+ $this->assertStringMatchesFormat(
"This message is in MIME format.
--=_%s
<h1>Header Title</h1>
<p>This is<br />the html text body.</p>
--=_%s--\n",
- $dummy->sentMessages[0]['body']
- );
- } else {
- $this->markTestSkipped();
- }
+ $dummy->sentMessages[0]['body']
+ );
$this->assertEquals(
array('recipient@example.com'),
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
From: sender@example.com
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: multipart/mixed; boundary="=_%s"
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
-
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
+
+ $this->assertStringMatchesFormat(
"This message is in MIME format.
--=_%s
--=_%s--\n",
- $dummy->sentMessages[0]['body']
- );
- } else {
- $this->markTestSkipped();
- }
+ $dummy->sentMessages[0]['body']
+ );
$this->assertEquals(
array('recipient@example.com'),
$dummy = Horde_Mail::factory('Mock');
$mail->send($dummy);
- // Need PHPUnit 3.5+
- if (method_exists($this, 'assertStringMatchesFormat')) {
- $this->assertStringMatchesFormat(
+ $this->assertStringMatchesFormat(
'Subject: My Subject
To: recipient@example.com
Message-ID: <%d.%s@mail.example.com>
Date: %s, %d %s %d %d:%d:%d %s%d
Content-Type: text/plain; charset=iso-8859-1; format=flowed; DelSp=Yes
MIME-Version: 1.0',
- str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
- );
- } else {
- $this->markTestSkipped();
- }
+ str_replace("\r\n", "\n", $dummy->sentMessages[0]['header_text'])
+ );
$this->assertEquals(
'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do