Skip to content

Commit

Permalink
Show the names of any Mailables which were sent unexpectedly in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ohnotnow committed Jan 11, 2020
1 parent 02a326c commit d86dbd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Illuminate/Support/Testing/Fakes/MailFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public function assertNotSent($mailable, $callback = null)
*/
public function assertNothingSent()
{
PHPUnit::assertEmpty($this->mailables, 'Mailables were sent unexpectedly.');
$mailableNames = collect($this->mailables)->values()->map(function ($mailable) {
return get_class($mailable);
})->join(', ');
PHPUnit::assertEmpty($this->mailables, 'The following Mailables were sent unexpectedly: ' . $mailableNames);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/SupportTestingMailFakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function testAssertNothingSent()
$this->fake->assertNothingSent();
$this->fail();
} catch (ExpectationFailedException $e) {
$this->assertThat($e, new ExceptionMessage('Mailables were sent unexpectedly.'));
$this->assertThat($e, new ExceptionMessage('The following Mailables were sent unexpectedly: Illuminate\Tests\Support\MailableStub'));
}
}
}
Expand Down

0 comments on commit d86dbd2

Please sign in to comment.