/** * */ function test_trigger() { $app = new App(['events' => ['foo' => [function () { return 'bar'; }]]]); Context::bind($app); $this->assertEquals('bar', ServiceFacade::trigger('foo')); }
/** * */ function test_invoke() { $app = new App(); $request = new Request(); $response = new Response(); $web = new Context($app); $next = function (Request $request, Response $response) { return $response; }; $this->assertEquals($response, $web($request, $response, $next)); $this->assertEquals($app, _Context::service()); }
/** * */ function test_service_does_not_exist() { $this->setExpectedException(\RuntimeException::class, 'Service does not exist'); Context::service(); }
/** * @param Request $request * @param Response $response * @param callable $next * @return Response */ function __invoke(Request $request, Response $response, callable $next) { _Context::bind($this->service()); return $next($request, $response); }