Skip to content

Commit

Permalink
[5.3] expectsEvents fired from ModelEvents (#15052)
Browse files Browse the repository at this point in the history
* WithoutEvents can fire ModelEvents to Test events fired ot of a Model event.

* added unit test

* fixed ci
  • Loading branch information
SeoFood authored and taylorotwell committed Aug 26, 2016
1 parent 3af7e70 commit dcfe40f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ public function doesntExpectEvents($events)
*/
protected function withoutEvents()
{
$this->withoutModelEvents();

$mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');

$mock->shouldReceive('fire')->andReturnUsing(function ($called) {
Expand Down
12 changes: 12 additions & 0 deletions tests/Foundation/FoundationExpectsModelEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public function expects_model_events_can_take_a_string_as_the_event_name()
EloquentTestModel::create(['field' => 1]);
}

/** @test */
public function expects_events_fires_on_model_events()
{
EloquentTestModel::created(function () {
event(ExampleEvent::class);
});

$this->expectsEvents(ExampleEvent::class);

EloquentTestModel::create(['field' => 1]);
}

/** @test */
public function unfired_events_can_be_checked_for()
{
Expand Down

0 comments on commit dcfe40f

Please sign in to comment.