Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge af3170e into be6598c
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Friedemann committed Jun 17, 2015
2 parents be6598c + af3170e commit 06e2794
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Writer/Mail.php
Expand Up @@ -90,6 +90,9 @@ public function __construct($mail, Transport\TransportInterface $transport = nul
if (is_array($mail)) {
$mail = MailMessageFactory::getInstance($mail);
}
if (is_array($transport)) {
$transport = Transport\Factory::create($transport);
}
}

// Ensure we have a valid mail message
Expand Down
31 changes: 31 additions & 0 deletions test/Writer/MailTest.php
Expand Up @@ -128,4 +128,35 @@ public function testConstructWithMailAsArrayOptions()

$this->assertAttributeInstanceOf('Zend\Mail\Message', 'mail', $writer);
}

public function testConstructWithMailTransportAsArrayOptions()
{
$messageOptions = [
'encoding' => 'UTF-8',
'from' => 'matthew@example.com',
'to' => 'zf-devteam@example.com',
'subject' => 'subject',
'body' => 'body',
];

$transportOptions = [
'type' => 'smtp',
'options' => [
'host' => 'test.dev',
'connection_class' => 'login',
'connection_config' => [
'username' => 'foo',
'smtp_password' => 'bar',
'ssl' => 'tls'
]
]
];

$writer = new MailWriter([
'mail' => $messageOptions,
'transport' => $transportOptions,
]);

$this->assertAttributeInstanceOf('Zend\Mail\Transport\Smtp', 'transport', $writer);
}
}

0 comments on commit 06e2794

Please sign in to comment.