示例#1
0
 public function testAdd()
 {
     $router = $this->app->router();
     $router->get('/', function ($req, $res) {
         $res->end('success');
     });
     $this->app->add($router);
     $response = $this->app->__invoke($this->newRequest('/'), new Response());
     $this->assertInstanceOf(TonisResponse::class, $response);
     $this->assertSame('success', $response->getBody()->__toString());
 }
示例#2
0
文件: AppTest.php 项目: ezimuel/tonis
 public function testDecoration()
 {
     $handler = function ($req, $res) {
         $this->assertInstanceOf(TonisRequest::class, $req);
         $this->assertInstanceOf(TonisResponse::class, $res);
         return $res->write('success');
     };
     $this->app->add($handler);
     $res = $this->app->__invoke($this->newRequest('/'), new Response());
     $this->assertInstanceOf(TonisResponse::class, $res);
     $this->assertSame('success', $res->getBody()->__toString());
     $res = $this->app->__invoke($this->newTonisRequest('/'), $this->newTonisResponse());
     $this->assertInstanceOf(TonisResponse::class, $res);
     $this->assertSame('success', $res->getBody()->__toString());
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public function register(App $app)
 {
     $app->add(function ($req, $res) {
         $this->ran = true;
         return $res;
     });
 }