-
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.
merge master and change exception checks to annotations
- Loading branch information
Showing
4 changed files
with
128 additions
and
50 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
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
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,7 +6,6 @@ | |
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Support\Testing\Fakes\MailFake; | ||
use PHPUnit\Framework\ExpectationFailedException; | ||
|
||
class MailFakeTest extends TestCase | ||
{ | ||
|
@@ -17,104 +16,94 @@ protected function setUp() | |
$this->mailable = new MailableStub; | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\MailableStub] mailable was not sent. | ||
*/ | ||
public function testAssertSent() | ||
{ | ||
try { | ||
$this->fake->assertSent(MailableStub::class); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The expected [Illuminate\Tests\Support\MailableStub] mailable was not sent. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
$this->fake->assertSent(MailableStub::class); | ||
|
||
$this->fake->to('[email protected]')->send($this->mailable); | ||
|
||
$this->fake->assertSent(MailableStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The unexpected [Illuminate\Tests\Support\MailableStub] mailable was sent. | ||
*/ | ||
public function testAssertNotSent() | ||
{ | ||
$this->fake->assertNotSent(MailableStub::class); | ||
|
||
$this->fake->to('[email protected]')->send($this->mailable); | ||
|
||
try { | ||
$this->fake->assertNotSent(MailableStub::class); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The unexpected [Illuminate\Tests\Support\MailableStub] mailable was sent. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
$this->fake->assertNotSent(MailableStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\MailableStub] mailable was sent 2 times instead of 1 times. | ||
*/ | ||
public function testAssertSentTimes() | ||
{ | ||
$this->fake->to('[email protected]')->send($this->mailable); | ||
$this->fake->to('[email protected]')->send($this->mailable); | ||
|
||
try { | ||
$this->fake->assertSent(MailableStub::class, 1); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The expected [Illuminate\Tests\Support\MailableStub] mailable was sent 2 times instead of 1 times. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
|
||
$this->fake->assertSent(MailableStub::class, 1); | ||
$this->fake->assertSent(MailableStub::class, 2); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\MailableStub] mailable was not queued. | ||
*/ | ||
public function testAssertQueued() | ||
{ | ||
try { | ||
$this->fake->assertQueued(MailableStub::class); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The expected [Illuminate\Tests\Support\MailableStub] mailable was not queued. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
$this->fake->assertQueued(MailableStub::class); | ||
|
||
$this->fake->to('[email protected]')->queue($this->mailable); | ||
|
||
$this->fake->assertQueued(MailableStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\MailableStub] mailable was queued 2 times instead of 1 times. | ||
*/ | ||
public function testAssertQueuedTimes() | ||
{ | ||
$this->fake->to('[email protected]')->queue($this->mailable); | ||
$this->fake->to('[email protected]')->queue($this->mailable); | ||
|
||
try { | ||
$this->fake->assertQueued(MailableStub::class, 1); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('The expected [Illuminate\Tests\Support\MailableStub] mailable was queued 2 times instead of 1 times. | ||
Failed asserting that false is true.', $exception->getMessage()); | ||
} | ||
|
||
$this->fake->assertQueued(MailableStub::class, 1); | ||
$this->fake->assertQueued(MailableStub::class, 2); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\QueueableMailableStub] mailable was not sent. | ||
*/ | ||
public function testSendQueuesAMailableThatShouldBeQueued() | ||
{ | ||
$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->assertSent(QueueableMailableStub::class); | ||
$this->fake->assertQueued(QueueableMailableStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage Mailables were sent unexpectedly. | ||
*/ | ||
public function testAssertNothingSent() | ||
{ | ||
$this->fake->assertNothingSent(); | ||
|
||
$this->fake->to('[email protected]')->send($this->mailable); | ||
|
||
try { | ||
$this->fake->assertNothingSent(); | ||
} catch (ExpectationFailedException $exception) { | ||
$this->assertEquals('Mailables were sent unexpectedly. | ||
Failed asserting that an array is empty.', $exception->getMessage()); | ||
} | ||
$this->fake->assertNothingSent(); | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Support; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\Testing\Fakes\QueueFake; | ||
|
||
class QueueFakeTest extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->fake = new QueueFake(new Application); | ||
$this->job = new JobStub; | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\JobStub] job was not pushed. | ||
*/ | ||
public function testAssertPushed() | ||
{ | ||
$this->fake->assertPushed(JobStub::class); | ||
|
||
$this->fake->push($this->job); | ||
|
||
$this->fake->assertPushed(JobStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The unexpected [Illuminate\Tests\Support\JobStub] job was pushed. | ||
*/ | ||
public function testAssertNotPushed() | ||
{ | ||
$this->fake->assertNotPushed(JobStub::class); | ||
|
||
$this->fake->push($this->job); | ||
|
||
$this->fake->assertNotPushed(JobStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\JobStub] job was not pushed. | ||
*/ | ||
public function testAssertPushedOn() | ||
{ | ||
$this->fake->push($this->job, '', 'foo'); | ||
|
||
$this->fake->assertPushedOn('bar', JobStub::class); | ||
|
||
$this->fake->assertPushedOn('foo', JobStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\JobStub] job was pushed 2 times instead of 1 times. | ||
*/ | ||
public function testAssertPushedTimes() | ||
{ | ||
$this->fake->push($this->job); | ||
$this->fake->push($this->job); | ||
|
||
$this->fake->assertPushed(JobStub::class, 1); | ||
|
||
$this->fake->assertPushed(JobStub::class, 2); | ||
} | ||
} | ||
|
||
class JobStub | ||
{ | ||
public function handle() | ||
{ | ||
// | ||
} | ||
} |