public function it_adds_the_app_title_to_the_page_title() { // init $config = new Config(); $this->config = $config; $request = new Request(); $response = new Response(); // request with appended app title $config->set('appTitle', 'app'); $config->set('pageTitleDelimiter', ' :: '); $request->setPath('/test'); $route = (object) ["path" => "/test", "type" => "template", "template" => "/test/fixtures/static-body.html.tpl", "model" => (object) ["pageTemplate" => "/test/fixtures/index.html.tpl", "pageTitle" => 'page']]; $this->handleTemplateRouteRequest($request, $response, $route); Assertions::assertContains('<title>page :: app</title>', $response->getBody(), 'should have page title and app title'); // request with empty page title $route->model->pageTitle = null; $this->handleTemplateRouteRequest($request, $response, $route); Assertions::assertContains('<title>app</title>', $response->getBody(), 'should have app title only'); // request with empty app title $route->model->pageTitle = 'page'; $config->set('appTitle', null); $this->handleTemplateRouteRequest($request, $response, $route); Assertions::assertContains('<title>page</title>', $response->getBody(), 'should have page title only'); }
public function it_throws_exceptions_for_invalid_controller_calls() { // init $this->setConfig(); $request = new Request($this->object->getWrappedObject()->config); $response = new Response($this->object->getWrappedObject()->config); // invalid controller class request $request->setPath('/test/invalid/class'); $this->shouldThrow('BackbonePhp\\Exception\\FileNotFoundException')->duringDispatchRequest($request, $response); // invalid controller method request $request->setPath('/test/invalid/method'); $this->shouldThrow('BackbonePhp\\Exception\\MethodNotFoundException')->duringDispatchRequest($request, $response); }