From 144b086407c100a810535c7f841b74114c1eb838 Mon Sep 17 00:00:00 2001 From: henderjon Date: Wed, 29 Oct 2014 08:15:21 -0500 Subject: [PATCH] adds an assertion to a test --- tests/PHPUnit/Dispatcher/DispatcherTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/PHPUnit/Dispatcher/DispatcherTest.php b/tests/PHPUnit/Dispatcher/DispatcherTest.php index 0e6a11c..c18871e 100644 --- a/tests/PHPUnit/Dispatcher/DispatcherTest.php +++ b/tests/PHPUnit/Dispatcher/DispatcherTest.php @@ -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