public function testTemplateHelperReturnsTemplateObjectInstance() { $app = new Bullet\App(array('template.cfg' => array('path' => $this->templateDir))); $app->path('template-test', function ($request) use($app) { $app->get(function ($request) use($app) { return $app->template('test'); }); }); $tpl = $app->run('GET', 'template-test'); $this->assertInstanceOf('Bullet\\View\\Template', $tpl); $this->assertEquals('<p>Test</p>', $tpl->content()); }
function testGetWithQueryString() { $app = new Bullet\App(); $app->path('test', function ($request) use($app) { $app->get(function ($request) { return 'foo=' . $request->foo; }); }); $req = new Bullet\Request('GET', '/test?foo=bar'); $res = $app->run($req); $this->assertEquals('foo=bar', $res->content()); }
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()); }