diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-02-05 07:51:11 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-02-05 07:51:11 +0000 |
commit | 1894a673bf0dfe35563f616091d7128596ef8d29 (patch) | |
tree | cf4ca19516474c76a1053afd6d210b45e56c6d98 /core/tests | |
parent | 9e2b84d406be322432cce65bfa16831718ba68c3 (diff) |
Move test-related extensions to Sendmail into a subclass that we only
use in the test code (Sendmail_For_Test).
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/Sendmail_Test.php | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/core/tests/Sendmail_Test.php b/core/tests/Sendmail_Test.php index d3800a26..4e813b16 100644 --- a/core/tests/Sendmail_Test.php +++ b/core/tests/Sendmail_Test.php @@ -30,7 +30,7 @@ class Sendmail_Test extends Unit_Test_Case { "Reply-To: public@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; - $result = Sendmail::factory() + $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") /* * @todo figure out why this test fails so badly, when the following @@ -40,7 +40,8 @@ class Sendmail_Test extends Unit_Test_Case { ->from("from@gallery3.com") ->subject("Test Email Unit test") ->message("The mail message body") - ->send()->send_text; + ->send() + ->send_text; $this->assert_equal($expected, $result); } @@ -51,12 +52,13 @@ class Sendmail_Test extends Unit_Test_Case { "Reply-To: reply-to@gallery3.com\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "The mail message body"; - $result = Sendmail::factory() + $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") ->subject("Test Email Unit test") ->reply_to("reply-to@gallery3.com") ->message("The mail message body") - ->send()->send_text; + ->send() + ->send_text; $this->assert_equal($expected, $result); } @@ -68,13 +70,14 @@ class Sendmail_Test extends Unit_Test_Case { "Content-type: text/html; charset=iso-8859-1\r\n" . "Subject: Test Email Unit test\r\n\r\n" . "<html><body><p>This is an html msg</p></body></html>"; - $result = Sendmail::factory() + $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") ->subject("Test Email Unit test") ->header("MIME-Version", "1.0") ->header("Content-type", "text/html; charset=iso-8859-1") ->message("<html><body><p>This is an html msg</p></body></html>") - ->send()->send_text; + ->send() + ->send_text; $this->assert_equal($expected, $result); } @@ -87,14 +90,25 @@ class Sendmail_Test extends Unit_Test_Case { "over forty characters If we get lucky we\n" . "might make it long enought to wrap a\n" . "couple of times."; - $result = Sendmail::factory() + $result = Sendmail_For_Test::factory() ->to("receiver@someemail.com") ->subject("Test Email Unit test") ->line_length(40) ->message("This is a long message that needs to go over forty characters " . "If we get lucky we might make it long enought to wrap a couple " . "of times.") - ->send()->send_text; + ->send() + ->send_text; $this->assert_equal($expected, $result); } +} + +class Sendmail_For_Test extends Sendmail { + static function factory() { + return new Sendmail_For_Test(); + } + + public function mail($to, $subject, $message, $headers) { + $this->send_text = "To: $to\r\n{$headers}\r\nSubject: $this->subject\r\n\r\n$message"; + } }
\ No newline at end of file |