Esempio n. 1
0
 public function testFindSite()
 {
     $site1 = $this->getMockSite(null, null, ['url' => 'http://my-site.com']);
     $site2 = $this->getMockSite(null, null, ['url' => 'http://my-site.com/hello']);
     $site3 = $this->getMockSite(null, null, ['url' => 'http://your-site.com']);
     $siteList = [$site1, $site2, $site3];
     $siteFactory = new CM_Site_SiteFactory($siteList);
     $this->assertEquals($site3, $siteFactory->findSite(new CM_Http_Request_Get('/foo', ['host' => 'your-site.com'])));
     $this->assertEquals($site1, $siteFactory->findSite(new CM_Http_Request_Get('/foo', ['host' => 'my-site.com'])));
     $this->assertEquals($site2, $siteFactory->findSite(new CM_Http_Request_Get('/hello/foo', ['host' => 'my-site.com'])));
     $this->assertNull($siteFactory->findSite(new CM_Http_Request_Get('/foo', ['host' => 'another-site.com'])));
 }
Esempio n. 2
0
 /**
  * @return CM_Site_Abstract
  */
 public function popPathSiteByMatch()
 {
     $siteFactory = new CM_Site_SiteFactory();
     $site = $siteFactory->findSite($this);
     if (null === $site) {
         $site = CM_Site_Abstract::factory();
     }
     $sitePath = $site->getUrlParser()->getPath();
     if ($this->hasPathPrefix($sitePath)) {
         $this->popPathPrefix($sitePath);
     }
     return $site;
 }