Пример #1
0
 /**
  *
  */
 function test_trigger()
 {
     $app = new App(['events' => ['foo' => [function () {
         return 'bar';
     }]]]);
     Context::bind($app);
     $this->assertEquals('bar', ServiceFacade::trigger('foo'));
 }
Пример #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());
 }
Пример #3
0
 /**
  *
  */
 function test_service_does_not_exist()
 {
     $this->setExpectedException(\RuntimeException::class, 'Service does not exist');
     Context::service();
 }
Пример #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);
 }