public function it_generates_a_status_object()
 {
     $config = new Config();
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/models.json');
     $this->config = $config;
     $request = new Request();
     $response = new Response();
     $route = (object) [];
     $this->handleStatusRequest($request, $response, $route)->shouldReturn($this);
     Assertions::assertEquals('application/json', $response->getHeader('Content-Type'), 'should set content type to JSON');
     Assertions::assertEquals('ok', $response->getBody()->status, 'should set status field');
     Assertions::assertTrue(is_int($response->getBody()->timestamp), 'should set timestamp field');
 }
 public function it_generates_a_frontend_config_object()
 {
     $config = new Config();
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/application.json');
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/groups.json');
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/models.json');
     $config->load(SpecHelper::rootPath() . 'src/BackbonePhp/Application/config/permissions.json');
     $this->config = $config;
     $request = new Request();
     $response = new Response();
     $route = (object) [];
     $this->handleFrontendConfigRequest($request, $response, $route)->shouldReturn($this);
     Assertions::assertEquals('application/json', $response->getHeader('Content-Type'), 'should set content type to JSON');
     Assertions::assertEquals('BackbonePHP', $response->getBody()->appName, 'should set status field');
     Assertions::assertFalse(isset($response->getBody()->groups), 'should net expose user groups');
     Assertions::assertFalse(isset($response->getBody()->permissions), 'should net expose permissions');
 }
Example #3
0
 public static function getDevConfig()
 {
     $config = new Config();
     $config->load(self::rootPath() . 'src/BackbonePhp/Application/config/permissions.json');
     $config->load(self::rootPath() . 'src/BackbonePhp/Application/config/groups.json');
     $config->load(self::rootPath() . 'src/BackbonePhp/Application/config/models.json');
     $config->load(self::rootPath() . 'src/BackbonePhp/Application/config/application.json');
     $config->load(self::fixturesPath() . 'dev-config.json');
     return $config;
 }
Example #4
0
 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');
 }
Example #5
0
 protected function setConfig()
 {
     $config = new Config();
     $config->load(SpecHelper::fixturesPath() . 'dev-config.json');
     $this->config = $config;
 }