Skip to content

Commit

Permalink
Merge pull request #10 from rpkamp/simplify-subject-check
Browse files Browse the repository at this point in the history
Add test to prove parsing empty subject works correctly
  • Loading branch information
rpkamp authored Aug 7, 2018
2 parents 4f9f9e9 + 9b8a587 commit 2bf6a4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Message/MessageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function fromMailhogResponse(array $mailhogResponse): Message
ContactCollection::fromString($headers['To'][0] ?? ''),
ContactCollection::fromString($headers['Cc'][0] ?? ''),
ContactCollection::fromString($headers['Bcc'][0] ?? ''),
isset($headers['Subject'][0]) ? $headers['Subject'][0] : '',
$headers['Subject'][0] ?? '',
!$mimeParts->isEmpty()
? $mimeParts->getBody()
: static::getBodyFrom($mailhogResponse['Content']),
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/MailhogClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ public function it_should_receive_all_message_data()
$this->assertEquals('Test body', $message->body);
}

/**
* @test
*/
public function it_should_handle_message_without_subject_correctly()
{
$this->sendMessage(
$this->createBasicMessage('[email protected]', '[email protected]', '', 'Test body')
);

/** @var Message $message */
$message = iterator_to_array($this->client->findAllMessages())[0];

$this->assertEquals('', $message->subject);
}

/**
* @test
*/
Expand Down

0 comments on commit 2bf6a4f

Please sign in to comment.