-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test a mailable that implements ShouldQueue is queued and not sent
- Loading branch information
1 parent
1052925
commit 3d9e734
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Support\Testing\Fakes\MailFake; | ||
use PHPUnit\Framework\ExpectationFailedException; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
|
||
class MailFakeTest extends TestCase | ||
{ | ||
|
@@ -88,6 +89,20 @@ public function testAssertQueuedTimes() | |
$this->fake->assertQueued(MailableStub::class, 2); | ||
} | ||
|
||
public function testSendQueuesAMailable() | ||
{ | ||
$this->fake->to('[email protected]')->send(new QueueableMailableStub); | ||
|
||
try { | ||
$this->fake->assertSent(QueueableMailableStub::class); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The expected [Illuminate\Tests\Support\QueueableMailableStub] mailable was not sent. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
|
||
$this->fake->assertQueued(QueueableMailableStub::class); | ||
} | ||
|
||
public function testAssertNothingSent() | ||
{ | ||
$this->fake->assertNothingSent(); | ||
|
@@ -120,3 +135,21 @@ public function build() | |
->withLastName('Otwell'); | ||
} | ||
} | ||
|
||
class QueueableMailableStub extends Mailable implements ShouldQueue | ||
{ | ||
public $framework = 'Laravel'; | ||
|
||
protected $version = '5.5'; | ||
|
||
/** | ||
* Build the message. | ||
* | ||
* @return $this | ||
*/ | ||
public function build() | ||
{ | ||
$this->with('first_name', 'Taylor') | ||
->withLastName('Otwell'); | ||
} | ||
} |