-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add assertDispatchedTimes for event fakes (#22528)
- Loading branch information
1 parent
514cba9
commit a55c4bf
Showing
2 changed files
with
85 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Illuminate\Tests\Support; | ||
|
||
use Mockery as m; | ||
use PHPUnit\Framework\TestCase; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
use Illuminate\Support\Testing\Fakes\EventFake; | ||
|
||
class SupportTestingEventFakeTest extends TestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->fake = new EventFake(m::mock(Dispatcher::class)); | ||
} | ||
|
||
public function testAssertDispacthed() | ||
{ | ||
$this->fake->dispatch(EventStub::class); | ||
|
||
$this->fake->assertDispatched(EventStub::class); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\EventStub] event was dispatched 2 times instead of 1 times. | ||
*/ | ||
public function testAssertDispatchedWithCallbackInt() | ||
{ | ||
$this->fake->dispatch(EventStub::class); | ||
$this->fake->dispatch(EventStub::class); | ||
|
||
$this->fake->assertDispatched(EventStub::class, 2); | ||
$this->fake->assertDispatched(EventStub::class, 1); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The expected [Illuminate\Tests\Support\EventStub] event was dispatched 2 times instead of 1 times. | ||
*/ | ||
public function testAssertDispatchedTimes() | ||
{ | ||
$this->fake->dispatch(EventStub::class); | ||
$this->fake->dispatch(EventStub::class); | ||
|
||
$this->fake->assertDispatchedTimes(EventStub::class, 2); | ||
$this->fake->assertDispatchedTimes(EventStub::class, 1); | ||
} | ||
|
||
/** | ||
* @expectedException PHPUnit\Framework\ExpectationFailedException | ||
* @expectedExceptionMessage The unexpected [Illuminate\Tests\Support\EventStub] event was dispatched. | ||
*/ | ||
public function testAssertNotDispatched() | ||
{ | ||
$this->fake->dispatch(EventStub::class); | ||
|
||
$this->fake->assertNotDispatched(EventStub::class); | ||
} | ||
} | ||
|
||
class EventStub | ||
{ | ||
} |