public function testMessageArray() { $result = $this->_message->setCharset('utf-8')->setTags('tag1')->setTo('*****@*****.**')->setFrom('*****@*****.**')->setReplyTo(['*****@*****.**', '*****@*****.**' => 'user'])->setCc('*****@*****.**')->setBcc('*****@*****.**')->setSubject(' <a>Testo ')->setGlobalMergeVars(['var1' => 'value1'])->setTextBody('testo<script>alert("ciao");</script>')->setHtmlBody('<a>testo</a>')->attachContent($this->getTestPdfBinary(), ['fileName' => '12.txt', 'contentType' => 'image/png'])->embed($this->getTestImagePath()); $this->assertInstanceOf('\\nickcv\\mandrill\\Message', $result); $array = $this->_message->getMandrillMessageArray(); $this->assertEquals('reply@email.it;user <*****@*****.**>', $array['headers']['Reply-To']); $this->assertEquals('<a>testo</a>', $array['html']); $this->assertEquals('testo', $array['text']); $this->assertEquals('<a>Testo', $array['subject']); $this->assertEquals('*****@*****.**', $array['from_email']); $this->assertEquals('My Application', $array['from_name']); $this->assertEquals([['name' => 'var1', 'content' => 'value1']], $array['global_merge_vars']); $to = $array['to']; $this->assertCount(3, $to); $this->assertEquals('*****@*****.**', $to[0]['email']); $this->assertNull($to[0]['name']); $this->assertEquals('to', $to[0]['type']); $this->assertEquals('*****@*****.**', $to[1]['email']); $this->assertNull($to[1]['name']); $this->assertEquals('cc', $to[1]['type']); $this->assertEquals('*****@*****.**', $to[2]['email']); $this->assertNull($to[2]['name']); $this->assertEquals('bcc', $to[2]['type']); $this->assertTrue($array['track_opens']); $this->assertTrue($array['track_clicks']); $this->assertContains('tag1', $array['tags']); $attachments = $array['attachments']; $this->assertCount(1, $attachments); $this->assertEquals($this->getTestPdfBinary(true), $attachments[0]['content']); $this->assertEquals('12.txt', $attachments[0]['name']); $this->assertEquals('image/png', $attachments[0]['type']); $embeds = $array['images']; $this->assertCount(1, $embeds); $this->assertEquals($this->getTestImageBinary(true), $embeds[0]['content']); $this->assertEquals('test.png', $embeds[0]['name']); $this->assertEquals('image/png', $embeds[0]['type']); $this->_message->enableTemplateDefaults(); $arrayTemplateDefaults = $this->_message->getMandrillMessageArray(); $this->assertEquals('*****@*****.**', $arrayTemplateDefaults['from_email']); $this->assertNull($arrayTemplateDefaults['from_name']); }