Example #1
0
 /**
  * 
  * @return array ['status', 'headers', 'body']
  */
 protected function _getResponse($envArgs)
 {
     \Slim\Environment::mock($envArgs);
     $app = new \Slim\Slim();
     new \Voce\Thermal\v1\API($app);
     $app->call();
     return $app->response()->finalize();
 }
 /**
  * Test custom error handler uses existing Response object
  */
 public function testErrorHandlerUsesCurrentResponseObject()
 {
     $s = new \Slim\Slim(array('debug' => false));
     $s->error(function (\Exception $e) use($s) {
         $r = $s->response();
         $r->status(503);
         $r->write('Foo');
         $r['X-Powered-By'] = 'Slim';
         echo 'Bar';
     });
     $s->get('/bar', function () {
         throw new \Exception('Foo');
     });
     $s->call();
     list($status, $header, $body) = $s->response()->finalize();
     $this->assertEquals(503, $status);
     $this->assertEquals('FooBar', $body);
     $this->assertEquals('Slim', $header['X-Powered-By']);
 }
Example #3
0
 /**
  * Test get current route
  */
 public function testGetCurrentRoute()
 {
     \Slim\Environment::mock(array('REQUEST_METHOD' => 'GET', 'SCRIPT_NAME' => '', 'PATH_INFO' => '/foo'));
     $app = new \Slim\Slim();
     $route1 = $app->get('/bar', function () {
         echo "Bar";
     });
     $route2 = $app->get('/foo', function () {
         echo "Foo";
     });
     $app->call();
     $this->assertSame($route2, $app->router()->getCurrentRoute());
 }