Skip to content

Commit

Permalink
adds an assertion to a test
Browse files Browse the repository at this point in the history
  • Loading branch information
henderjon committed Oct 29, 2014
1 parent db00f5c commit 144b086
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/PHPUnit/Dispatcher/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ function test_dispatch(){
$lambda = $dispatcher->dispatch($route);

// note the invokation -- the lambda wraps the routed object (controller)
// simple invokation calls __invoke on the controller
// simple invokation calls __invoke on the controller -- our test returns $this
// in the real world, __invoke should do something meaningful ...
$this->assertTrue($lambda() InstanceOf DispatchableInterface);
// since __invoke returns $this, call a method of our controller
$this->assertEquals($lambda()->getCalled() , 323);
// the lambda acts as the wrapper for our object and allows us to pass method names and args to our controller
$this->assertEquals($lambda("getCalled") , 323);
$this->assertEquals($lambda("getCalled", [4]) , 327);
// in a frontend controller, your wrapper would call a method (or __invoke) on our desired object and that
// method might in turn return a callable (perhaps a view) that is then sent somewhere else or
Expand Down

0 comments on commit 144b086

Please sign in to comment.