예제 #1
0
 /**
  * Setup for tests
  *
  * @return void
  */
 public function setup()
 {
     $this->domains = ['reliv.com' => ['domain' => 'local.reliv.com', 'primaryDomain' => null, 'languageId' => 'eng', 'siteId' => 1, 'countryId' => 'USA'], 'www.reliv.com' => ['domain' => 'local.reliv.com', 'primaryDomain' => 'reliv.com', 'languageId' => 'eng', 'siteId' => 1, 'countryId' => 'USA']];
     $this->redirects = ['/requestOne' => ['requestUrl' => '/requestOne', 'redirectUrl' => 'reliv.com/redirectOne'], '/requestTwo' => ['requestUrl' => '/requestTwo', 'redirectUrl' => 'reliv.com/redirectTwo']];
     $config = [];
     $this->currentSite = new Site();
     $this->currentSite->setSiteId(1);
     $this->currentSite->setStatus(Site::STATUS_ACTIVE);
     $domain = new Domain();
     $domain->setDomainId(1);
     $domain->setDomainName('reliv.com');
     $this->currentSite->setDomain($domain);
     $this->redirectRepo = $this->getMockBuilder('\\Rcm\\Repository\\Redirect')->disableOriginalConstructor()->getMock();
     $map = [];
     foreach ($this->redirects as $key => $redirect) {
         $redirectEntity = new Redirect();
         $redirectEntity->setRedirectUrl($redirect['requestUrl']);
         $redirectEntity->setRedirectUrl($redirect['redirectUrl']);
         $map[] = [$key, $this->currentSite->getSiteId(), $redirectEntity];
     }
     $this->redirectRepo->expects($this->any())->method('getRedirect')->will($this->returnValueMap($map));
     //////////////
     $this->siteServiceMock = $this->getMockBuilder(SiteService::class)->disableOriginalConstructor()->getMock();
     $this->siteServiceMock->expects($this->any())->method('getCurrentSite')->will($this->returnValue($this->currentSite));
     $this->siteServiceMock->expects($this->any())->method('isConsoleRequest')->will($this->returnValue(false));
     $this->redirectServiceMock = $this->getMockBuilder(RedirectService::class)->disableOriginalConstructor()->getMock();
     $this->domainRedirectServiceMock = $this->getMockBuilder(DomainRedirectService::class)->disableOriginalConstructor()->getMock();
     $this->localeServiceMock = $this->getMockBuilder(LocaleService::class)->disableOriginalConstructor()->getMock();
     $this->routeListener = new RouteListener($this->siteServiceMock, $this->redirectServiceMock, $this->domainRedirectServiceMock, $this->localeServiceMock);
 }
예제 #2
0
 public function createSite($domainName, $country, $language, $theme)
 {
     $em = $this->entityManager;
     $domain = new Domain();
     $domain->setDomainName($domainName);
     $em->persist($domain);
     /** @var \Rcm\Repository\Country $countryRepo */
     $countryRepo = $em->getRepository('\\Rcm\\Entity\\Country');
     $countryEntity = $countryRepo->getCountryByString($country);
     /** @var \Rcm\Repository\Language $languageRepo */
     $languageRepo = $em->getRepository('\\Rcm\\Entity\\Language');
     $languageEntity = $languageRepo->getLanguageByString($language);
     $site = new Site();
     $site->setDomain($domain);
     $site->setCountry($countryEntity);
     $site->setLanguage($languageEntity);
     $site->setTheme($theme);
     $site->setSiteLayout('default');
     $site->setStatus('A');
     $this->createSiteContainers($site, $theme);
     $this->createPages($site, $theme);
     $em->persist($site);
     $em->flush();
     return $site;
 }
예제 #3
0
 /**
  * Setup for tests
  *
  * @return void
  */
 public function setup()
 {
     $this->domains = ['reliv.com' => ['domain' => 'local.reliv.com', 'primaryDomain' => null, 'languageId' => 'eng', 'siteId' => 1, 'countryId' => 'USA'], 'www.reliv.com' => ['domain' => 'local.reliv.com', 'primaryDomain' => 'reliv.com', 'languageId' => 'eng', 'siteId' => 1, 'countryId' => 'USA']];
     $this->redirects = ['/requestOne' => ['requestUrl' => '/requestOne', 'redirectUrl' => 'reliv.com/redirectOne'], '/requestTwo' => ['requestUrl' => '/requestTwo', 'redirectUrl' => 'reliv.com/redirectTwo']];
     $config = [];
     $this->currentSite = new Site();
     $this->currentSite->setSiteId(1);
     $this->currentSite->setStatus('A');
     $domain = new Domain();
     $domain->setDomainId(1);
     $domain->setDomainName('reliv.com');
     $this->currentSite->setDomain($domain);
     $this->redirectRepo = $this->getMockBuilder('\\Rcm\\Repository\\Redirect')->disableOriginalConstructor()->getMock();
     $map = [];
     foreach ($this->redirects as $key => $redirect) {
         $redirectEntity = new Redirect();
         $redirectEntity->setRedirectUrl($redirect['requestUrl']);
         $redirectEntity->setRedirectUrl($redirect['redirectUrl']);
         $map[] = [$key, $this->currentSite->getSiteId(), $redirectEntity];
     }
     $this->redirectRepo->expects($this->any())->method('getRedirect')->will($this->returnValueMap($map));
     $this->routeListener = new RouteListener($this->currentSite, $this->redirectRepo, new \Zend\Validator\Ip(), $config);
 }
예제 #4
0
파일: SiteTest.php 프로젝트: reliv/Rcm
 /**
  * Test Clone
  *
  * @return void
  *
  * @covers \Rcm\Entity\Site
  */
 public function testClone()
 {
     $domain = new Domain();
     $domain->setDomainId(23);
     $language = new Language();
     $language->setLanguageId(55);
     $country = new Country();
     $country->setIso3('USA');
     $site = ['siteId' => '1000', 'owner' => 'wshafer', 'domain' => $domain, 'theme' => 'theme1', 'siteLayout' => 'layoutOne', 'siteTitle' => 'My Title', 'language' => $language, 'status' => Site::STATUS_ACTIVE, 'favicon' => 'icon.jpg', 'loginRequired' => true, 'loginPage' => 'login.html', 'aclRoles' => 'role1,role2', 'pages' => [0 => ['pageId' => '200', 'name' => 'pageOne', 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'lastPublished' => new \DateTime('yesterday'), 'revisions' => [0 => ['revisionId' => 100, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'publishedDate' => new \DateTime('yesterday'), 'published' => true, 'md5' => 'revisionMD5', 'instances' => [0 => ['pluginWrapperId' => 43, 'layoutContainer' => 'layoutOne', 'renderOrder' => 0, 'height' => 32, 'width' => 100, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 80, 'plugin' => 'MockPlugin', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 45, 'layoutContainer' => 'layoutTwo', 'renderOrder' => 1, 'height' => 33, 'width' => 101, 'divFloat' => 'none', 'instance' => ['pluginInstanceId' => 81, 'plugin' => 'MockPlugin2', 'siteWide' => true, 'displayName' => 'TestSiteWide', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]], 1 => ['revisionId' => 101, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('-1 month'), 'publishedDate' => new \DateTime('-1 month'), 'published' => false, 'md5' => 'revision2MD5', 'instances' => [0 => ['pluginWrapperId' => 47, 'layoutContainer' => 'layoutThree', 'renderOrder' => 2, 'height' => 33, 'width' => 102, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 82, 'plugin' => 'MockPlugin3', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 49, 'layoutContainer' => 'layoutFour', 'renderOrder' => 3, 'height' => 34, 'width' => 103, 'divFloat' => 'left', 'instance' => ['pluginInstanceId' => 83, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]], 1 => ['pageId' => '200', 'name' => 'pageOne', 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'lastPublished' => new \DateTime('yesterday'), 'revisions' => [0 => ['revisionId' => 100, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'publishedDate' => new \DateTime('yesterday'), 'published' => true, 'md5' => 'revisionMD5', 'instances' => [0 => ['pluginWrapperId' => 61, 'layoutContainer' => 'layoutOne', 'renderOrder' => 0, 'height' => 32, 'width' => 100, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 84, 'plugin' => 'MockPlugin', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 60, 'layoutContainer' => 'layoutTwo', 'renderOrder' => 1, 'height' => 33, 'width' => 101, 'divFloat' => 'none', 'instance' => ['pluginInstanceId' => 85, 'plugin' => 'MockPlugin2', 'siteWide' => true, 'displayName' => 'TestSiteWide', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]], 1 => ['revisionId' => 101, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('-1 month'), 'publishedDate' => new \DateTime('-1 month'), 'published' => false, 'md5' => 'revision2MD5', 'instances' => [0 => ['pluginWrapperId' => 63, 'layoutContainer' => 'layoutThree', 'renderOrder' => 2, 'height' => 33, 'width' => 102, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 86, 'plugin' => 'MockPlugin3', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 49, 'layoutContainer' => 'layoutFour', 'renderOrder' => 3, 'height' => 34, 'width' => 103, 'divFloat' => 'left', 'instance' => ['pluginInstanceId' => 87, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]]], 'containers' => [0 => ['containerId' => '200', 'name' => 'containerOne', 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'lastPublished' => new \DateTime('yesterday'), 'revisions' => [0 => ['revisionId' => 100, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'publishedDate' => new \DateTime('yesterday'), 'published' => true, 'md5' => 'revisionMD5', 'instances' => [0 => ['pluginWrapperId' => 43, 'layoutContainer' => 'layoutOne', 'renderOrder' => 0, 'height' => 32, 'width' => 100, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 998, 'plugin' => 'MockPlugin', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 45, 'layoutContainer' => 'layoutTwo', 'renderOrder' => 1, 'height' => 33, 'width' => 101, 'divFloat' => 'none', 'instance' => ['pluginInstanceId' => 88, 'plugin' => 'MockPlugin2', 'siteWide' => true, 'displayName' => 'TestSiteWide', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]], 1 => ['revisionId' => 101, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('-1 month'), 'publishedDate' => new \DateTime('-1 month'), 'published' => false, 'md5' => 'revision2MD5', 'instances' => [0 => ['pluginWrapperId' => 47, 'layoutContainer' => 'layoutThree', 'renderOrder' => 2, 'height' => 33, 'width' => 102, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 89, 'plugin' => 'MockPlugin3', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 49, 'layoutContainer' => 'layoutFour', 'renderOrder' => 3, 'height' => 34, 'width' => 103, 'divFloat' => 'left', 'instance' => ['pluginInstanceId' => 90, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]], 1 => ['containerId' => '200', 'name' => 'containerOne', 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'lastPublished' => new \DateTime('yesterday'), 'revisions' => [0 => ['revisionId' => 100, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('yesterday'), 'publishedDate' => new \DateTime('yesterday'), 'published' => true, 'md5' => 'revisionMD5', 'instances' => [0 => ['pluginWrapperId' => 43, 'layoutContainer' => 'layoutOne', 'renderOrder' => 0, 'height' => 32, 'width' => 100, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 91, 'plugin' => 'MockPlugin', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 45, 'layoutContainer' => 'layoutTwo', 'renderOrder' => 1, 'height' => 33, 'width' => 101, 'divFloat' => 'none', 'instance' => ['pluginInstanceId' => 92, 'plugin' => 'MockPlugin2', 'siteWide' => true, 'displayName' => 'TestSiteWide', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]], 1 => ['revisionId' => 101, 'author' => 'Westin Shafer', 'createdDate' => new \DateTime('-1 month'), 'publishedDate' => new \DateTime('-1 month'), 'published' => false, 'md5' => 'revision2MD5', 'instances' => [0 => ['pluginWrapperId' => 47, 'layoutContainer' => 'layoutThree', 'renderOrder' => 2, 'height' => 33, 'width' => 102, 'divFloat' => 'right', 'instance' => ['pluginInstanceId' => 93, 'plugin' => 'MockPlugin3', 'siteWide' => false, 'displayName' => null, 'instanceConfig' => ['var1' => 1, 'var2' => 2], 'md5' => 'firstMd5']], 1 => ['pluginWrapperId' => 49, 'layoutContainer' => 'layoutFour', 'renderOrder' => 3, 'height' => 34, 'width' => 103, 'divFloat' => 'left', 'instance' => ['pluginInstanceId' => 94, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]]]];
     $this->site->setSiteId($site['siteId']);
     $this->site->setDomain($site['domain']);
     $this->site->setTheme($site['theme']);
     $this->site->setSiteLayout($site['siteLayout']);
     $this->site->setSiteTitle($site['siteTitle']);
     $this->site->setLanguage($site['language']);
     $this->site->setStatus($site['status']);
     $this->site->setFavIcon($site['favicon']);
     $this->site->setLoginPage($site['loginPage']);
     foreach ($site['pages'] as $page) {
         $pageEntity = new Page();
         $pageEntity->setPageId($page['pageId']);
         $pageEntity->setName($page['name']);
         $pageEntity->setAuthor($page['author']);
         $pageEntity->setCreatedDate($page['createdDate']);
         $pageEntity->setLastPublished($page['lastPublished']);
         $pageEntity->setSite($this->site);
         foreach ($page['revisions'] as $index => $revisionData) {
             $revision = $this->getRevision($revisionData);
             if ($index === 0) {
                 $pageEntity->setPublishedRevision($revision);
             } elseif ($index === 1) {
                 $pageEntity->setStagedRevision($revision);
             }
             $pageEntity->addRevision($revision);
         }
         $this->site->addPage($pageEntity);
     }
     foreach ($site['containers'] as $container) {
         $containerEntity = new Container();
         $containerEntity->setContainerId($container['containerId']);
         $containerEntity->setName($container['name']);
         $containerEntity->setAuthor($container['author']);
         $containerEntity->setCreatedDate($container['createdDate']);
         $containerEntity->setLastPublished($container['lastPublished']);
         $containerEntity->setSite($this->site);
         foreach ($container['revisions'] as $index => $revisionData) {
             $revision = $this->getRevision($revisionData);
             if ($index === 0) {
                 $containerEntity->setPublishedRevision($revision);
             } elseif ($index === 1) {
                 $containerEntity->setStagedRevision($revision);
             }
             $containerEntity->addRevision($revision);
         }
         $this->site->addContainer($containerEntity);
     }
     /** Test site entity is setup correctly */
     $this->assertCount(1, $this->site->getPages());
     $this->assertCount(1, $this->site->getContainers());
     $original = $this->site;
     $cloned = clone $this->site;
     $this->assertNotEquals($original->getSiteId(), $cloned->getSiteId());
     $this->assertNull($cloned->getSiteId());
     $this->assertNull($cloned->getDomain());
     $this->assertEquals($original->getTheme(), $cloned->getTheme());
     $this->assertEquals($original->getSiteLayout(), $cloned->getSiteLayout());
     $this->assertEquals($original->getSiteTitle(), $cloned->getSiteTitle());
     $this->assertEquals($original->getLanguage(), $cloned->getLanguage());
     $this->assertEquals($original->getStatus(), $cloned->getStatus());
     $this->assertEquals($original->getFavIcon(), $cloned->getFavIcon());
     $this->assertEquals($original->getLoginPage(), $cloned->getLoginPage());
     $clonedPages = $cloned->getPages();
     /** @var \Rcm\Entity\Page $page */
     foreach ($clonedPages as $page) {
         $this->assertNull($page->getPageId());
         $clonedRevision = $page->getPublishedRevision();
         if (empty($clonedRevision)) {
             continue;
         }
         $this->assertNull($clonedRevision->getRevisionId());
         $clonedWrappers = $clonedRevision->getPluginWrappers();
         /** @var \Rcm\Entity\PluginWrapper $wrapper */
         foreach ($clonedWrappers as $wrapper) {
             $this->assertNull($wrapper->getPluginWrapperId());
             $this->assertNull($wrapper->getInstance()->getInstanceId());
         }
     }
     $clonedContainers = $cloned->getContainers();
     /** @var \Rcm\Entity\Container $container */
     foreach ($clonedContainers as $container) {
         $this->assertNull($container->getContainerId());
         $clonedRevision = $container->getPublishedRevision();
         if (empty($clonedRevision)) {
             continue;
         }
         $this->assertNull($clonedRevision->getRevisionId());
         $clonedWrappers = $clonedRevision->getPluginWrappers();
         /** @var \Rcm\Entity\PluginWrapper $wrapper */
         foreach ($clonedWrappers as $wrapper) {
             $this->assertNull($wrapper->getPluginWrapperId());
             $this->assertNull($wrapper->getInstance()->getInstanceId());
         }
     }
 }