Exemplo n.º 1
0
 public function testNestedRoutesInsideParamCallback()
 {
     $app = new Bullet\App();
     $app->path('admin', function ($request) use($app) {
         $app->path('client', function ($request) use($app) {
             $app->param('int', function ($request, $id) use($app) {
                 $app->path('toggleVisiblity', function ($request) use($app, $id) {
                     $app->path('item', function ($request) use($app, $id) {
                         $app->get(function ($request) use($app) {
                             return "deep";
                         });
                     });
                 });
             });
         });
     });
     $result = $app->run(new Bullet\Request('GET', '/admin/client/1/toggleVisiblity/item'));
     $this->assertEquals('deep', $result->content());
 }
Exemplo n.º 2
0
 function testOptionsHeaderForParamPaths()
 {
     $app = new Bullet\App();
     $req = new Bullet\Request('OPTIONS', '/test/this_is_a_slug');
     $app->path('test', function ($request) use($app) {
         $app->param('slug', function ($request, $param) use($app) {
             $app->get(function ($request) {
                 return 'GET';
             });
             $app->post(function ($request) {
                 return 'POST';
             });
         });
     });
     $res = $app->run($req);
     $this->assertEquals('OK', $res->content());
     $this->assertEquals('GET,POST,OPTIONS', $res->header('Allow'));
 }
Exemplo n.º 3
0
 /**
  * Register the callback for the given parameter
  *
  * @param string $param
  * @param \Closure $callback
  * @return $this
  */
 public function registerParameter($param, \Closure $callback)
 {
     $this->app->param($param, $callback);
     return $this;
 }