Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Util/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function getRecipients(): array

public function getSubject(): string
{
return $this->subject;
return $this->subject ?? '';
}

public function getSource(): string
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/Module/MailCatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ public function testDontSeeInLastEmailSubject()
$mailcatcher->dontSeeInLastEmailSubject('Hello world');
}

public function testDontSeeInLastEmailSubjectWithoutSubject()
{
$mailcatcher = new MailCatcherTest_TestClass();
$mailcatcher->setLastMessage(new Email(1, [], null, ''));

$mailcatcher->dontSeeInLastEmailSubject('Hello world');
}

public function testSeeInLastEmailSubjectWithoutSubjectFails()
{
$mailcatcher = new MailCatcherTest_TestClass();
$mailcatcher->setLastMessage(new Email(1, [], null, ''));

$this->expectException(AssertionFailedError::class);

$mailcatcher->seeInLastEmailSubject('Hello world');
}

public function testLastMessageToNoMessages()
{
$handler = new MockHandler([
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/Util/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ public function testGetters()
$this->assertEquals('Source body', $email->getSource());
}

public function testMissingSubjectIsEmpty()
{
$email = Email::createFromMailcatcherData([
'id' => 1,
'recipients' => ['some@email.com'],
'subject' => null,
'source' => 'Source body'
]);

$this->assertSame('', $email->getSubject());
}

public function testCreateFromMailcatcherData()
{
$email = Email::createFromMailcatcherData([
Expand Down
Loading