-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make dispatchable trait more testable
- Loading branch information
1 parent
eeceb86
commit 0aa39b1
Showing
4 changed files
with
82 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php namespace spec\Laracasts\Commander\Events; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Prophecy\Argument; | ||
use Laracasts\Commander\Events\Contracts\Dispatcher; | ||
|
||
class DispatchableSpec extends ObjectBehavior { | ||
|
||
function let() | ||
{ | ||
$this->beAnInstanceOf(HandlerStub::class); | ||
} | ||
|
||
function it_dispatches_stuff(Dispatcher $dispatcher) | ||
{ | ||
$this->setDispatcher($dispatcher); | ||
|
||
$this->dispatchEventsFor(new EntityStub); | ||
|
||
$dispatcher->dispatch([])->shouldBeCalled(); | ||
} | ||
|
||
} | ||
|
||
|
||
class HandlerStub { | ||
use \Laracasts\Commander\Events\DispatchableTrait; | ||
} | ||
|
||
class EntityStub { | ||
|
||
public function releaseEvents() | ||
{ | ||
return []; | ||
} | ||
|
||
} |
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,12 @@ | ||
<?php namespace Laracasts\Commander\Events\Contracts; | ||
|
||
interface Dispatcher { | ||
|
||
/** | ||
* Dispatch all raised events. | ||
* | ||
* @param array $events | ||
*/ | ||
public function dispatch(array $events); | ||
|
||
} |
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