From 8cba263bbcc182839695c068abf145195a07bffc Mon Sep 17 00:00:00 2001 From: uckelman Date: Sat, 20 Mar 2010 13:46:11 +0000 Subject: Completed tests for most EmailMessage methods. git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6619 67b53d14-2c14-4ace-a08f-0dab2b34000c --- src/EMailMessage.php | 73 ---------------------------------------- src/EmailMessage.php | 73 ++++++++++++++++++++++++++++++++++++++++ test/1 | 84 +++++++++++++++++++++++++++++++++++++++++++++++ test/EmailMessageTest.php | 82 +++++++++++++++++++++++++++++++++++---------- 4 files changed, 221 insertions(+), 91 deletions(-) delete mode 100644 src/EMailMessage.php create mode 100644 src/EmailMessage.php create mode 100644 test/1 diff --git a/src/EMailMessage.php b/src/EMailMessage.php deleted file mode 100644 index 9d921a9..0000000 --- a/src/EMailMessage.php +++ /dev/null @@ -1,73 +0,0 @@ -msg = MailMessage::decode_raw_message($input); - } - - public function getSource() { -# FIXME: fill in! - return null; - } - - public function getPostId() { -# FIXME: get from message-id to post-id database - return null; - } - - public function getFrom() { - return EMailMessage::parse_addr($this->msg->headers['from']); - } - - public function getSubject() { - return $this->msg->headers['subject']; - } - - public function getMessageId() { - return $this->msg->headers['message-id']; - } - - public function getInReplyTo() { - return $this->msg->headers['in-reply-to']; - } - - public function getReferences() { - return $this->msg->headers['references']; - } - - public function getBody() { - return $this->msg->body; - } - - protected static function decode_raw_message($input) { - $params['include_bodies'] = true; - $params['decode_bodies'] = true; - $params['decode_headers'] = true; - $params['input'] = $input; - $params['crlf'] = "\r\n"; - - $msg = Mail_mimeDecode::decode($params); - - if (count($msg->headers) == 1 && array_key_exists(null, $msg->headers)) { - # An empty message has one null header. - trigger_error('No message', E_USER_ERROR); - } - - return $msg; - } - - protected static function parse_addr($s) { - $addr = Mail_RFC822::parseAddressList($s); - return strtolower($addr[0]->mailbox . '@' . $addr[0]->host); - } -} - -?> diff --git a/src/EmailMessage.php b/src/EmailMessage.php new file mode 100644 index 0000000..d6ff762 --- /dev/null +++ b/src/EmailMessage.php @@ -0,0 +1,73 @@ +msg = EMailMessage::decode_raw_message($input); + } + + public function getSource() { +# FIXME: fill in! + return null; + } + + public function getPostId() { +# FIXME: get from message-id to post-id database + return null; + } + + public function getFrom() { + return EMailMessage::parse_addr($this->msg->headers['from']); + } + + public function getSubject() { + return $this->msg->headers['subject']; + } + + public function getMessageId() { + return $this->msg->headers['message-id']; + } + + public function getInReplyTo() { + return $this->msg->headers['in-reply-to']; + } + + public function getReferences() { + return $this->msg->headers['references']; + } + + public function getBody() { + return $this->msg->body; + } + + protected static function decode_raw_message($input) { + $params['include_bodies'] = true; + $params['decode_bodies'] = true; + $params['decode_headers'] = true; + $params['input'] = $input; + $params['crlf'] = "\r\n"; + + $msg = Mail_mimeDecode::decode($params); + + if (count($msg->headers) == 1 && array_key_exists(null, $msg->headers)) { + # An empty message has one null header. + trigger_error('No message', E_USER_ERROR); + } + + return $msg; + } + + protected static function parse_addr($s) { + $addr = Mail_RFC822::parseAddressList($s); + return strtolower($addr[0]->mailbox . '@' . $addr[0]->host); + } +} + +?> diff --git a/test/1 b/test/1 new file mode 100644 index 0000000..18ee1ff --- /dev/null +++ b/test/1 @@ -0,0 +1,84 @@ +Return-Path: +X-Original-To: uckelman@nomic.net +Delivered-To: uckelman@nomic.net +Received-SPF: none (charybdis.ellipsis.cx: domain of messages-bounces@forums.vassalengine.org does not designate permitted sender hosts) +Received: from abante.lunarpages.com (abante.lunarpages.com [67.210.126.35]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by charybdis.ellipsis.cx (Postfix) with ESMTPS id 55C5910077 + for ; Tue, 2 Mar 2010 02:42:38 -0700 (MST) +Received: from localhost ([127.0.0.1] helo=abante.lunarpages.com) + by abante.lunarpages.com with esmtp (Exim 4.69) + (envelope-from ) + id 1NmOcY-0003Wf-6c; Tue, 02 Mar 2010 01:42:30 -0800 +Received: from charybdis.ellipsis.cx ([66.253.49.165]) + by abante.lunarpages.com with esmtp (Exim 4.69) + (envelope-from ) id 1NmOcW-0003WM-Fi + for messages@forums.vassalengine.org; Tue, 02 Mar 2010 01:42:28 -0800 +Received: by charybdis.ellipsis.cx (Postfix, from userid 500) + id 33F0310091; Tue, 2 Mar 2010 02:42:28 -0700 (MST) +To: VASSAL Engine Forums Mailing List +Subject: Re: [Developers]Re: Adding developers? +In-reply-to: <1267473003.m2f.17543@www.vassalengine.org> +References: <1267171317.m2f.17507@www.vassalengine.org> + <1267473003.m2f.17543@www.vassalengine.org> +Comments: In-reply-to "wlk" + message dated "Mon, 01 Mar 2010 11:50:03 -0800." +From: Joel Uckelman +Date: Tue, 02 Mar 2010 10:42:28 +0100 +Message-Id: <20100302094228.33F0310091@charybdis.ellipsis.cx> +X-BeenThere: messages@forums.vassalengine.org +X-Mailman-Version: 2.1.11.cp3 +Precedence: list +Reply-To: VASSAL Engine Forums Mailing List +List-Id: VASSAL Engine Forums Mailing List + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Sender: messages-bounces@forums.vassalengine.org +Errors-To: messages-bounces@forums.vassalengine.org +X-ACL-Warn: { +X-AntiAbuse: This header was added to track abuse, please include it with any abuse report +X-AntiAbuse: Primary Hostname - abante.lunarpages.com +X-AntiAbuse: Original Domain - nomic.net +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - forums.vassalengine.org +X-Source: +X-Source-Args: +X-Source-Dir: +X-Bogosity: Unsure, tests=bogofilter, spamicity=0.500000, version=1.2.0 + +Thus spake "wlk": +> +> uckelman wrote: +> > How close are you guys to a 3.1-compatble release, BTW? We've had at least +> > one bug report every day since the release of 3.1.0 about VASL being +> > incompatible with 3.1... +> +> +> Actually, I fixed like 5 bugs now, and there's none left I am aware of, at le +> ast the ones related to VASL binaries. +> I'm daily using 5.9 with 3.1.13 and didn't notice anything wrong. +> We were waiting for 3.1.14 to be released to publish VASL 5.9. +> + +Oh! I didn't know you were waiting for 3.1.14. I can put together a test +build tonight, and if people try it out to confirm that it's ok, we can +release tomorrow. + +-- +J. + +_______________________________________________ +Messages mailing list +Messages@forums.vassalengine.org +http://forums.vassalengine.org/mailman/listinfo/messages_forums.vassalengine.org + diff --git a/test/EmailMessageTest.php b/test/EmailMessageTest.php index f544477..ffbd666 100644 --- a/test/EmailMessageTest.php +++ b/test/EmailMessageTest.php @@ -2,40 +2,86 @@ require_once('PHPUnit/Framework.php'); +require_once('src/EmailMessage.php'); + class EmailMessageTest extends PHPUnit_Framework_TestCase { - - /** @test */ - public function testGetSource() { + + public function provider() { + return array( + array(array( + 'file' => __DIR__ . '/1', + 'source' => '', + 'post_id' => '', + 'from' => 'uckelman@nomic.net', + 'subject' => 'Re: [Developers]Re: Adding developers?', + 'message_id' => '<20100302094228.33F0310091@charybdis.ellipsis.cx>', + 'in_reply_to' => '<1267473003.m2f.17543@www.vassalengine.org>', + 'references' => '<1267171317.m2f.17507@www.vassalengine.org> <1267473003.m2f.17543@www.vassalengine.org>', + 'body' => '' + )) + ); } - /** @test */ - public function testGetPostId() { + /** + * @dataProvider provider + */ + public function testGetSource($expected) { + $this->markTestIncomplete(); } - /** @test */ - public function testGetFrom() { + /** + * @dataProvider provider + */ + public function testGetPostId($expected) { + $this->markTestIncomplete(); } - /** @test */ - public function testGetSubject() { + /** + * @dataProvider provider + */ + public function testGetFrom($expected) { + $msg = new EmailMessage(file_get_contents($expected['file'])); + $this->assertEquals($expected['from'], $msg->getFrom()); + } + + /** + * @dataProvider provider + */ + public function testGetSubject($expected) { + $msg = new EmailMessage(file_get_contents($expected['file'])); + $this->assertEquals($expected['subject'], $msg->getSubject()); } - /** @test */ - public function testGetMessageId() { + /** + * @dataProvider provider + */ + public function testGetMessageId($expected) { + $msg = new EmailMessage(file_get_contents($expected['file'])); + $this->assertEquals($expected['message_id'], $msg->getMessageId()); } - /** @test */ - public function testGetInReplyTo() { + /** + * @dataProvider provider + */ + public function testGetInReplyTo($expected) { + $msg = new EmailMessage(file_get_contents($expected['file'])); + $this->assertEquals($expected['in_reply_to'], $msg->getInReplyTo()); } - /** @test */ - public function testGetReferences() { + /** + * @dataProvider provider + */ + public function testGetReferences($expected) { + $msg = new EmailMessage(file_get_contents($expected['file'])); + $this->assertEquals($expected['references'], $msg->getReferences()); } - /** @test */ - public function testGetBody() { + /** + * @dataProvider provider + */ + public function testGetBody($expected) { + $this->markTestIncomplete(); } - } ?> -- cgit v1.2.3