From: Jan Schneider Date: Thu, 6 Jan 2011 17:31:39 +0000 (+0100) Subject: We require PHPUnit 3.5 now. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4f8b56495a71274665c185971c3b4d897cacc0e5;p=horde.git We require PHPUnit 3.5 now. --- diff --git a/framework/Alarm/test/Horde/Alarm/HandlerTest.php b/framework/Alarm/test/Horde/Alarm/HandlerTest.php index 26f25129b..2c1468d4c 100644 --- a/framework/Alarm/test/Horde/Alarm/HandlerTest.php +++ b/framework/Alarm/test/Horde/Alarm/HandlerTest.php @@ -64,30 +64,30 @@ class Horde_Alarm_HandlerTest extends PHPUnit_Framework_TestCase 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 = << -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); @@ -98,8 +98,11 @@ EOR; 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']); } } diff --git a/framework/Mime/test/Horde/Mime/MailTest.php b/framework/Mime/test/Horde/Mime/MailTest.php index e5d722cf6..01ea9f22d 100644 --- a/framework/Mime/test/Horde/Mime/MailTest.php +++ b/framework/Mime/test/Horde/Mime/MailTest.php @@ -43,9 +43,7 @@ class Horde_Mime_MailTest extends PHPUnit_Framework_TestCase $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 @@ -54,11 +52,8 @@ User-Agent: Horde Application Framework 4 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", @@ -85,9 +80,7 @@ MIME-Version: 1.0', $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 @@ -96,11 +89,8 @@ User-Agent: Horde Application Framework 4 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", @@ -128,9 +118,7 @@ MIME-Version: 1.0', $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?= From: sender@example.com @@ -141,11 +129,8 @@ 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 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", @@ -184,9 +169,7 @@ Content-Transfer-Encoding: quoted-printable', $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 @@ -195,15 +178,10 @@ User-Agent: Horde Application Framework 4 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 @@ -225,11 +203,8 @@ Content-Transfer-Encoding: base64 WnfDtmxmIEJveGvDpG1wZmVyIGphZ2VuIFZpa3RvciBxdWVyIMO8YmVyIGRlbiBncm/Dn2VuIFN5 bHRlciBEZWljaC4K --=_%s--\n", - $dummy->sentMessages[0]['body'] - ); - } else { - $this->markTestSkipped(); - } + $dummy->sentMessages[0]['body'] + ); $this->assertEquals( array('recipient@example.com'), @@ -249,9 +224,7 @@ bHRlciBEZWljaC4K $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 @@ -260,11 +233,8 @@ User-Agent: Horde Application Framework 4 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.", @@ -290,9 +260,7 @@ MIME-Version: 1.0', $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 @@ -301,11 +269,8 @@ User-Agent: Horde Application Framework 4 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( "

Header Title

\n

This is
the html text body.

", @@ -327,9 +292,7 @@ MIME-Version: 1.0', $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 @@ -338,15 +301,10 @@ User-Agent: Horde Application Framework 4 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 @@ -365,11 +323,8 @@ Content-Description: HTML Version of Message

Header Title

This is
the html text body.

--=_%s--\n", - $dummy->sentMessages[0]['body'] - ); - } else { - $this->markTestSkipped(); - } + $dummy->sentMessages[0]['body'] + ); $this->assertEquals( array('recipient@example.com'), @@ -397,9 +352,7 @@ Content-Description: HTML Version of Message $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 @@ -408,15 +361,10 @@ User-Agent: Horde Application Framework 4 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 @@ -453,11 +401,8 @@ end --=_%s--\n", - $dummy->sentMessages[0]['body'] - ); - } else { - $this->markTestSkipped(); - } + $dummy->sentMessages[0]['body'] + ); $this->assertEquals( array('recipient@example.com'), @@ -506,9 +451,7 @@ end $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> @@ -516,11 +459,8 @@ User-Agent: Horde Application Framework 4 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