diff options
author | uckelman <uckelman@nomic.net> | 2010-03-20 15:33:53 +0000 |
---|---|---|
committer | uckelman <uckelman@nomic.net> | 2010-03-20 15:33:53 +0000 |
commit | 78fe98c7f6f2097d466b6351de0c259cf2db57a9 (patch) | |
tree | 4535cc5492b8e4b78813e226124b47adfba9e460 /test | |
parent | 946b326a1b3aa6f1f01161c4c385a3efb1d24d0a (diff) |
Refactored to make EmailMessage abstract.
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6621 67b53d14-2c14-4ace-a08f-0dab2b34000c
Diffstat (limited to 'test')
-rw-r--r-- | test/MessageTest.php (renamed from test/EmailMessageTest.php) | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/test/EmailMessageTest.php b/test/MessageTest.php index c3269f5..2338e60 100644 --- a/test/EmailMessageTest.php +++ b/test/MessageTest.php @@ -1,16 +1,16 @@ <?php require_once('PHPUnit/Framework.php'); +require_once('src/Message.php'); -require_once('src/EmailMessage.php'); - -class EmailMessageTest extends PHPUnit_Framework_TestCase { +class MessageTest extends PHPUnit_Framework_TestCase { public function provider() { return array( array(array( - 'file' => file_get_contents(__DIR__ . '/1'), - 'source' => '', + 'class' => 'MailmanMessage', + 'data' => file_get_contents(__DIR__ . '/1'), + 'source' => 'messages@forums.vassalengine.org', 'post_id' => '', 'from' => 'uckelman@nomic.net', 'subject' => 'Re: [Developers]Re: Adding developers?', @@ -22,6 +22,12 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { ); } + protected function buildMessage($params) { + require_once('src/' . $params['class'] . '.php'); + $cl = new ReflectionClass($params['class']); + return $cl->newInstance($params['data']); + } + /** * @dataProvider provider */ @@ -40,7 +46,7 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { * @dataProvider provider */ public function testGetFrom($expected) { - $msg = new EmailMessage($expected['file']); + $msg = $this->buildMessage($expected); $this->assertEquals($expected['from'], $msg->getFrom()); } @@ -48,7 +54,7 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { * @dataProvider provider */ public function testGetSubject($expected) { - $msg = new EmailMessage($expected['file']); + $msg = $this->buildMessage($expected); $this->assertEquals($expected['subject'], $msg->getSubject()); } @@ -56,7 +62,7 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { * @dataProvider provider */ public function testGetMessageId($expected) { - $msg = new EmailMessage($expected['file']); + $msg = $this->buildMessage($expected); $this->assertEquals($expected['message_id'], $msg->getMessageId()); } @@ -64,7 +70,7 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { * @dataProvider provider */ public function testGetInReplyTo($expected) { - $msg = new EmailMessage($expected['file']); + $msg = $this->buildMessage($expected); $this->assertEquals($expected['in_reply_to'], $msg->getInReplyTo()); } @@ -72,7 +78,7 @@ class EmailMessageTest extends PHPUnit_Framework_TestCase { * @dataProvider provider */ public function testGetReferences($expected) { - $msg = new EmailMessage($expected['file']); + $msg = $this->buildMessage($expected); $this->assertEquals($expected['references'], $msg->getReferences()); } |