Beispiel #1
0
 /**
  * {@inheritDoc}
  */
 public function register(App $app)
 {
     $app->add(function ($req, $res) {
         $this->ran = true;
         return $res;
     });
 }
Beispiel #2
0
 public function configure(App $app)
 {
     $router = $app->router();
     $router->get('/', function ($req, $res) {
         $res->write('foo');
     });
     return $router;
 }
Beispiel #3
0
 public function testRegister()
 {
     $app = new App();
     $container = $app->getContainer();
     $package = new Package(['alias' => 'foo']);
     $package->register($app);
     $this->assertTrue($container->has('foo'));
 }
Beispiel #4
0
 public function testRedirectToRoute()
 {
     $this->app->get('/foo', function ($req, Response $res) {
         return $res->write('foo');
     })->name('foo');
     $response = $this->response->redirectToRoute('foo');
     $this->assertNotEmpty($response->getHeader('Location'));
     $this->assertSame('/foo', $response->getHeader('Location')[0]);
 }
Beispiel #5
0
 public function testDecoration()
 {
     $result = $this->app->__invoke($this->newRequest('/'), new Response(), function ($req, $res) {
         $this->assertInstanceOf(TonisRequest::class, $req);
         $this->assertInstanceOf(TonisResponse::class, $res);
         $res->write('success');
     });
     $this->assertSame('success', $result->getBody()->__toString());
     $result = $this->app->__invoke($this->newTonisRequest('/'), $this->newTonisResponse(), function ($req, $res) {
         $this->assertInstanceOf(TonisRequest::class, $req);
         $this->assertInstanceOf(TonisResponse::class, $res);
         $res->write('success');
     });
     $this->assertSame('success', $result->getBody()->__toString());
 }
Beispiel #6
0
 /**
  * Attempts to render the `$template` with `$params` using the ViewManager. If a strategy
  * is not available then the Tonis fallback strategy is used.
  *
  * @param string $template
  * @param array $params
  * @return string
  */
 public function render($template, array $params = [])
 {
     return $this->write($this->app->getView()->render($template, $params));
 }
Beispiel #7
0
 protected function setUp()
 {
     $app = new App();
     $app->package(new DoctrineORMPackage());
     $this->app = $app;
 }