Exemplo n.º 1
0
 /**
  *
  */
 function test_trigger()
 {
     $app = new App(['events' => ['foo' => [function () {
         return 'bar';
     }]]]);
     Context::bind($app);
     $this->assertEquals('bar', ServiceFacade::trigger('foo'));
 }
Exemplo n.º 2
0
 /**
  *
  */
 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());
 }
Exemplo n.º 3
0
 /**
  *
  */
 function test_service_does_not_exist()
 {
     $this->setExpectedException(\RuntimeException::class, 'Service does not exist');
     Context::service();
 }
Exemplo n.º 4
0
 /**
  * @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);
 }