コード例 #1
0
 /**
  * Make an instance of EmailMD\Entity\Message
  *
  * @param object $overview overview of the information in the headers of the given message
  * @param string $body     Message body
  *
  * @access public
  * @return EmailMD\Entity\Message
  */
 public function make($overview, $body)
 {
     $message = new Message();
     foreach ($overview as $property => $value) {
         if (isset($this->_map[$property])) {
             $message->{$this->_map[$property]}($this->_decode($value));
         }
     }
     $message->setBody($this->_decode($body));
     return $message;
 }
コード例 #2
0
 /**
  * Test make, passing some fields known
  *
  * @access public
  * @return null
  */
 public function testMakeHasSomeKnownFields()
 {
     $Factory = new EntityFactory();
     $overview = new \StdClass();
     $overview->subject = '=?ISO-8859-1?Q?Ultima_chamada_para_o_LiquidaShow!?=';
     $overview->from = 'Google <*****@*****.**>';
     $overview->to = '=?ISO-8859-1?Q?Destinatarios_de_e-mail_de_resumo?=';
     $overview->deleted = '0';
     $overview->seen = '1';
     $overview->draft = '0';
     $overview->udate = '1410728740';
     $body = 'New Proin ut quam eros. Donec sed lobortis diam.\\n Nulla nec odio lacus.';
     $expected = new Message();
     $expected->setSubject('Ultima chamada para o LiquidaShow!');
     $expected->setFrom('Google <*****@*****.**>');
     $expected->setTo('Destinatarios de e-mail de resumo');
     $expected->setDeleted('0');
     $expected->setSeen('1');
     $expected->setDraft('0');
     $expected->setUdate('1410728740');
     $expected->setBody('New Proin ut quam eros. Donec sed lobortis diam.\\n Nulla nec odio lacus.');
     $result = $Factory->make($overview, $body);
     $this->assertInstanceOf('EmailMD\\Entity\\Message', $result);
     $this->assertEquals($result, $expected);
 }
コード例 #3
0
ファイル: MessageTest.php プロジェクト: rochamarcelo/EmailMD
 /**
  * Test for set and gets
  *
  * @access public
  * @return null
  */
 public function testSetGetAll()
 {
     $array = array('subject' => 'Integer elementum massa', 'from' => 'Google <*****@*****.**>', 'to' => '*****@*****.**', 'date' => 'Sun, 10 Sep 2014 21:09:35 +0000 (UTC)', 'message_id' => '<*****@*****.**>', 'references' => 'yyyyyy@test', 'in_reply_to' => 'xxxxx@test', 'size' => '15250', 'uid' => '111111', 'number' => '22222', 'recent' => '0', 'flagged' => '1', 'answered' => '0', 'deleted' => '0', 'seen' => '1', 'draft' => '0', 'udate' => '1410728740', 'body' => 'Proin ut quam eros. Donec sed lobortis diam. Nulla nec odio lacus. Quisque porttitor egestas dolor in placerat.');
     $message = new Message();
     $message->setSubject($array['subject']);
     $expected = $array['subject'];
     $result = $message->getSubject();
     $this->assertSame($result, $expected);
     $message->setFrom($array['from']);
     $expected = $array['from'];
     $result = $message->getFrom();
     $this->assertSame($result, $expected);
     $message->setTo($array['to']);
     $expected = $array['to'];
     $result = $message->getTo();
     $this->assertSame($result, $expected);
     $message->setDate($array['date']);
     $expected = $array['date'];
     $result = $message->getDate();
     $this->assertSame($result, $expected);
     $message->setMessageId($array['message_id']);
     $expected = $array['message_id'];
     $result = $message->getMessageId();
     $this->assertSame($result, $expected);
     $message->setReferences($array['references']);
     $expected = $array['references'];
     $result = $message->getReferences();
     $this->assertSame($result, $expected);
     $message->setInReplyTo($array['in_reply_to']);
     $expected = $array['in_reply_to'];
     $result = $message->getInReplyTo();
     $this->assertSame($result, $expected);
     $message->setSize($array['size']);
     $expected = $array['size'];
     $result = $message->getSize();
     $this->assertSame($result, $expected);
     $message->setUid($array['uid']);
     $expected = $array['uid'];
     $result = $message->getUid();
     $this->assertSame($result, $expected);
     $message->setNumber($array['number']);
     $expected = $array['number'];
     $result = $message->getNumber();
     $this->assertSame($result, $expected);
     $message->setRecent($array['recent']);
     $expected = false;
     $result = $message->getRecent();
     $this->assertSame($result, $expected);
     $message->setRecent('1');
     $expected = true;
     $result = $message->getRecent();
     $this->assertSame($result, $expected);
     $message->setFlagged($array['flagged']);
     $expected = true;
     $result = $message->getFlagged();
     $this->assertSame($result, $expected);
     $message->setFlagged('0');
     $expected = false;
     $result = $message->getFlagged();
     $this->assertSame($result, $expected);
     $message->setAnswered($array['answered']);
     $expected = false;
     $result = $message->getAnswered();
     $this->assertSame($result, $expected);
     $message->setAnswered('1');
     $expected = true;
     $result = $message->getAnswered();
     $this->assertSame($result, $expected);
     $message->setDeleted($array['deleted']);
     $expected = false;
     $result = $message->getDeleted();
     $this->assertSame($result, $expected);
     $message->setDeleted('1');
     $expected = true;
     $result = $message->getDeleted();
     $this->assertSame($result, $expected);
     $message->setSeen($array['seen']);
     $expected = true;
     $result = $message->getSeen();
     $this->assertSame($result, $expected);
     $message->setSeen('0');
     $expected = false;
     $result = $message->getSeen();
     $this->assertSame($result, $expected);
     $message->setDraft($array['draft']);
     $expected = false;
     $result = $message->getDraft();
     $this->assertSame($result, $expected);
     $message->setDraft('1');
     $expected = true;
     $result = $message->getDraft();
     $this->assertSame($result, $expected);
     $message->setUdate($array['udate']);
     $expected = $array['udate'];
     $result = $message->getUdate();
     $this->assertSame($result, $expected);
 }