From 7750ae52e7b73af2f7d4f4964dfb2ac007f9c6b6 Mon Sep 17 00:00:00 2001 From: Joel Uckelman Date: Mon, 27 Feb 2012 03:16:45 +0100 Subject: Converted some tests to use dataProviders. --- test/build_email_test.php | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/test/build_email_test.php b/test/build_email_test.php index ae88388..51ccb44 100644 --- a/test/build_email_test.php +++ b/test/build_email_test.php @@ -3,20 +3,17 @@ require_once(__DIR__ . '/../src/build_email.php'); class build_email_test extends PHPUnit_Framework_TestCase { - - public function test_build_text_edit() { - $this->assertEquals( - "[This message has been edited.] - -foo bar", - build_text('foo bar', true) - ); + /** @dataProvider build_text_data */ + public function test_build_text($text, $edit, $expected) { + $this->assertEquals($expected, build_text($text, $edit)); } - public function test_build_text_no_edit() { - $this->assertEquals( - 'foo bar', - build_text('foo bar', false) + public function build_text_data() { + return array( + array('foo bar', false, 'foo bar'), + array('foo bar', true, "[This message has been edited.] + +foo bar") ); } @@ -30,24 +27,16 @@ http://www.example.com/viewtopic.php?p=42#p42", ); } - public function test_build_from_nonascii() { - $this->assertEquals( - '=?UTF-8?B?SGVpesO2bHLDvGNrc3Rvw59hYmTDpG1wZnVuZw==?= ', - build_from('Heizölrückstoßabdämpfung', 'foo@example.com') - ); - } - - public function test_build_from_ascii() { - $this->assertEquals( - 'Joel Uckelman ', - build_from('Joel Uckelman', 'uckelman@nomic.net') - ); + /** @dataProvider build_from_data */ + public function test_build_from($name, $email, $expected) { + $this->assertEquals($expected, build_from($name, $email)); } - public function test_build_from_rfc822_specials() { - $this->assertEquals( - '"L.Tankersley" ', - build_from('L.Tankersley', 'leland53@comcast.net') + public function build_from_data() { + return array( + array('Heizölrückstoßabdämpfung', 'foo@example.com', '=?UTF-8?B?SGVpesO2bHLDvGNrc3Rvw59hYmTDpG1wZnVuZw==?= '), + array('Joel Uckelman', 'uckelman@nomic.net', 'Joel Uckelman '), + array('L.Tankersley', 'leland53@comcast.net', '"L.Tankersley" ') ); } -- cgit v1.2.3