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

Commit

Permalink
Merge branch 'hotfix/3252'
Browse files Browse the repository at this point in the history
Close #3252
  • Loading branch information
weierophinney committed Dec 19, 2012
2 parents 47db7c0 + 8e4298c commit 6a3b2a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/Zend/Log/Writer/Mail.php
Expand Up @@ -85,6 +85,9 @@ public function __construct($mail, Transport\TransportInterface $transport = nul
}

if (is_array($mail)) {
if (isset($mail['subject_prepend_text'])) {
$this->setSubjectPrependText($mail['subject_prepend_text']);
}
$transport = isset($mail['transport']) ? $mail['transport'] : null;
$mail = isset($mail['mail']) ? $mail['mail'] : null;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/ZendTest/Log/Writer/MailTest.php
Expand Up @@ -83,4 +83,30 @@ public function testSetSubjectPrependText()
$this->assertContains('an info message', $contents);
$this->assertContains('Subject: test', $contents);
}

public function testConstructWithOptions()
{
$message = new MailMessage();
$transport = new Transport\File();
$options = new Transport\FileOptions(array(
'path' => __DIR__,
'callback' => function (Transport\File $transport) {
return MailTest::FILENAME;
},
));
$transport->setOptions($options);

$formatter = new \Zend\Log\Formatter\Simple();
$writer = new MailWriter(array(
'formatter' => $formatter,
'mail' => $message,
'transport' => $transport,
'subject_prepend_text' => 'subject prepend',
));

$this->assertAttributeEquals($message, 'mail', $writer);
$this->assertAttributeEquals($transport, 'transport', $writer);
$this->assertAttributeEquals($formatter, 'formatter', $writer);
$this->assertAttributeEquals('subject prepend', 'subjectPrependText', $writer);
}
}

0 comments on commit 6a3b2a1

Please sign in to comment.