Пример #1
0
 protected function setUp()
 {
     $this->initAutoload();
     $this->bbapp = $this->getBBApp();
     $this->initDb($this->bbapp);
     $this->initAcl();
     $this->bbapp->start();
     // craete site
     $this->site = new Site();
     $this->site->setLabel('sitelabel');
     $this->site->setServerName('www.example.org');
     // craete layout
     $this->layout = new Layout();
     $this->layout->setSite($this->site);
     $this->layout->setLabel('defaultLayoutLabel');
     $this->layout->setPath($this->bbapp->getBBDir() . '/Rest/Tests/Fixtures/Controller/defaultLayout.html.twig');
     $this->layout->setData(json_encode(array('templateLayouts' => array('title' => 'zone_1234567'))));
     $this->site->addLayout($this->layout);
     $this->getEntityManager()->persist($this->layout);
     $this->getEntityManager()->persist($this->site);
     $this->getEntityManager()->flush();
 }
Пример #2
0
 public function testGetUriRequested()
 {
     // Starting with a site without servername and simulate an HTTPS request
     $site = new Site();
     self::$app->getContainer()->set('site', $site);
     unset($GLOBALS['argv']);
     self::$app->setIsStarted(true);
     $request = self::$app->getRequest();
     $request->server->add(['SCRIPT_URL' => '/public/fake/fake.html', 'SCRIPT_URI' => 'https://www.fakeserver.com/public/fake/fake.html', 'HTTP_HOST' => 'www.fakeserver.com', 'SERVER_NAME' => 'www.fakeserver.com', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '443', 'HTTPS' => 'on', 'DOCUMENT_ROOT' => '/home/web/fakeroot', 'SCRIPT_FILENAME' => '/home/web/fakeroot/public/index.php', 'REQUEST_URI' => '/public/fake/fake.html', 'SCRIPT_NAME' => '/public/index.php']);
     // No site provided, the request is used
     $routeCollection = new RouteCollection(self::$app);
     $this->assertEquals('http://www.backbee.com', $routeCollection->getUri('http://www.backbee.com'));
     $this->assertEquals('https://www.fakeserver.com/public/', $routeCollection->getUri());
     $this->assertEquals('https://www.fakeserver.com/public/images/', $routeCollection->getUri(null, null, null, RouteCollection::IMAGE_URL));
     $this->assertEquals('https://www.fakeserver.com/public/', $routeCollection->getUri(null, '.html'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.html', $routeCollection->getUri('/fake'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.htm', $routeCollection->getUri('fake.htm', '.html'));
     $this->assertEquals('https://www.fakeserver.com/public/fake.html', $routeCollection->getUri('fake', '.html'));
     // A site is provided, the base URL and the protocol can't be predicted
     $otherSite = new Site();
     $otherSite->setServerName('other.fakeserver.com');
     $this->assertEquals('http://www.backbee.com', $routeCollection->getUri('http://www.backbee.com', null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/', $routeCollection->getUri(null, null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/images/', $routeCollection->getUri(null, null, $otherSite, RouteCollection::IMAGE_URL));
     $this->assertEquals('http://other.fakeserver.com/', $routeCollection->getUri(null, '.html', $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.html', $routeCollection->getUri('/fake', null, $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.htm', $routeCollection->getUri('fake.htm', '.html', $otherSite));
     $this->assertEquals('http://other.fakeserver.com/fake.html', $routeCollection->getUri('fake', '.html', $otherSite));
 }