/** * testSetGet * * @return void */ public function testSetGet() { $entity = new RcmGoogleAnalytics(); $data = ['id' => 123, 'trackingId' => 'UA00000', 'verificationCode' => 'ggggg', 'siteId' => 321, 'host' => 'test.example.com']; $domain = new Domain(); $domain->setDomainName('test.example.com'); $data['site'] = new Site(); $data['site']->setSiteId(3211); $data['site']->setDomain($domain); $entity->setId($data['id']); $this->assertEquals($data['id'], $entity->getId()); $entity->setTrackingId($data['trackingId']); $this->assertEquals($data['trackingId'], $entity->getTrackingId()); $this->assertTrue($entity->hasTracking()); $entity->setVerificationCode($data['verificationCode']); $this->assertEquals($data['verificationCode'], $entity->getVerificationCode()); $this->assertTrue($entity->hasVerificationCode()); $this->assertNull($entity->getHost()); $siteNoDomain = new Site(); $siteNoDomain->setSiteId(3311); $entity->setSite($siteNoDomain); $this->assertNull($entity->getHost()); $entity->setSite($data['site']); $this->assertEquals($data['site'], $entity->getSite()); $this->assertEquals($data['site']->getSiteId(), $entity->getSiteId()); $this->assertEquals($data['site']->getDomain()->getDomainName(), $entity->getHost()); $array = $entity->toArray(); $this->assertTrue(is_array($array)); $this->assertEquals($data['host'], $array['host']); }
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; }
/** * Get resource provider with mocks * * @param bool $skipSite Skip Site Mock setup * * @return ResourceProvider */ protected function getProviderWithMocks($skipSite = false) { $mockReturn = []; $currdomain = new Domain(); $currdomain->setDomainName('curr.reliv.com'); $currpage = new Page(); $currpage->setName('curr-page'); $currsite = new Site(); $currsite->setDomain($currdomain); $currsite->setSiteId(1); $currsite->addPage($currpage); if (!$skipSite) { $domain = new Domain(); $domain->setDomainName('test.reliv.com'); $page = new Page(); $page->setName('test-page'); $site = new Site(); $site->setDomain($domain); $site->setSiteId(10); $site->addPage($page); $mockReturn[] = $site; } $mockSiteRepo = $this->getMockBuilder('\\Rcm\\Repository\\Site')->disableOriginalConstructor()->getMock(); $mockSiteRepo->expects($this->any())->method('getSites')->will($this->returnValue($mockReturn)); /** @var \Rcm\Repository\Site $mockSiteRepo */ /** @var \Rcm\Service\PluginManager $mockPluginManager */ return new ResourceProvider($this->config, $mockSiteRepo, $currsite); }
/** * Set the Primary Domain. * * @param Domain|null $primaryDomain * * @return void */ public function setPrimaryDomain($primaryDomain) { if (empty($primaryDomain)) { $this->primaryDomain = null; $this->primaryId = null; return; } $this->primaryDomain = $primaryDomain; $this->primaryId = $primaryDomain->getDomainId(); }
/** * Test Check Domain Redirects To Primary * * @return void * * @covers \Rcm\EventListener\RouteListener */ public function testCheckDomainRedirectsToPrimary() { $serverParams = new Parameters(['HTTP_HOST' => 'www.reliv.com']); $primary = $this->currentSite->getDomain(); $domain = new Domain(); $domain->setDomainId(1); $domain->setDomainName('www.reliv.com'); $domain->setPrimary($primary); $this->currentSite->setDomain($domain); $this->domainRedirectServiceMock->expects($this->any())->method('getPrimaryRedirectUrl')->will($this->returnValue($primary->getDomainName())); $request = new Request(); $request->setServer($serverParams); $event = new MvcEvent(); $event->setRequest($request); $actual = $this->routeListener->checkDomain($event); $this->assertTrue($actual instanceof Response); $this->assertEquals(302, $actual->getStatusCode()); $this->assertEquals('//' . $this->currentSite->getDomain()->getPrimary()->getDomainName(), $actual->getHeaders()->get('Location')->getFieldValue()); }
public function testUtilities() { $data = []; $data['domainId'] = 123; $data['domain'] = 'test'; $data['primaryDomain'] = new Domain(); $objOne = new Domain(); $objOne->populate($data); $this->assertEquals($data['domainId'], $objOne->getDomainId()); $this->assertEquals($data['domain'], $objOne->getDomainName()); $this->assertEquals($data['primaryDomain'], $objOne->getPrimary()); $objTwo = new Domain(); $objTwo->populateFromObject($objOne); $this->assertEquals($objOne->getDomainId(), $objTwo->getDomainId()); $this->assertEquals($objOne->getDomainName(), $objTwo->getDomainName()); $this->assertEquals($objOne->getPrimary(), $objTwo->getPrimary()); $json = json_encode($objTwo); $this->assertJson($json); $iterator = $objTwo->getIterator(); $this->assertInstanceOf('\\ArrayIterator', $iterator); $array = $objTwo->toArray(); $this->assertEquals($data['domainId'], $array['domainId']); $this->assertEquals($data['domain'], $array['domain']); $this->assertEquals($data['primaryDomain'], $array['primaryDomain']); }
public function testToArray() { $unit = new Redirect(); $site = new Site(); $domain = new Domain(); $site->setSiteId(28); $domain->setDomainName('test.com'); $site->setDomain($domain); $unit->setSite($site); $result = $unit->toArray(); $this->assertEquals('test.com', $result['domain']); $this->assertEquals(28, $result['siteId']); }
/** * 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()); } } }
/** * Get Test Page Data for Page Repo Mocks * * @param integer $pageId PageID * @param integer $pageName PageName * @param integer $revisionId RevisionId * @param string $pageType PageType * @param boolean $useStaged Use staged revision instead of published * @param string $siteLayoutOverride Layout Override * * @return array */ protected function getPageData($pageId, $pageName, $revisionId, $pageType = 'n', $useStaged = false, $siteLayoutOverride = null) { $country = new Country(); $country->setCountryName('United States'); $country->setIso2('US'); $country->setIso3('USA'); $language = new Language(); $language->setLanguageId(1); $language->setIso6391('en'); $language->setIso6392b('eng'); $language->setIso6392t('eng'); $domain = new Domain(); $domain->setDomainId(1); $domain->setDomainName('reliv.com'); $site = new Site(); $site->setSiteId(1); $site->setCountry($country); $site->setLanguage($language); $site->setLoginPage('login'); $site->setNotFoundPage('not-found'); $site->setDomain($domain); $revision = new Revision(); $revision->setRevisionId($revisionId); $revision->setAuthor('Westin Shafer'); $revision->setCreatedDate(new \DateTime()); $revision->setPublishedDate(new \DateTime()); $page = new Page(); $page->setSite($site); $page->setName($pageName); $page->setPageId($pageId); $page->setPageType($pageType); $page->addRevision($revision); $page->setPublishedRevision($revision); if ($useStaged) { $page->setStagedRevision($revision); } $page->setPageId(22); $page->setSiteLayoutOverride($siteLayoutOverride); return $page; }
/** * populate @todo some properties are missing * * @param array $data * @param array $ignore * * @return void */ public function populate(array $data, array $ignore = []) { if (!empty($data['siteId']) && !in_array('siteId', $ignore)) { $this->setSiteId($data['siteId']); } if (!empty($data['domain']) && $data['domain'] instanceof Domain && !in_array('domain', $ignore)) { $this->setDomain($data['domain']); } if (!empty($data['domain']) && is_array($data['domain']) && !in_array('domain', $ignore)) { // is this right? $domain = new Domain(); $domain->populate($data['domain']); $this->setDomain($domain); } if (!empty($data['theme']) && !in_array('theme', $ignore)) { $this->setTheme($data['theme']); } if (!empty($data['siteLayout']) && !in_array('siteLayout', $ignore)) { $this->setSiteLayout($data['siteLayout']); } if (!empty($data['siteTitle']) && !in_array('siteTitle', $ignore)) { $this->setSiteTitle($data['siteTitle']); } if (!empty($data['language']) && $data['language'] instanceof Language && !in_array('language', $ignore)) { $this->setLanguage($data['language']); } if (!empty($data['language']) && is_array($data['language']) && !in_array('language', $ignore)) { $language = new Language(); $language->populate($data['language']); $this->setLanguage($language); } if (!empty($data['country']) && $data['country'] instanceof Country && !in_array('country', $ignore)) { $this->setCountry($data['country']); } if (!empty($data['country']) && is_array($data['country']) && !in_array('country', $ignore)) { $country = new Country(); $country->populate($data['country']); $this->setCountry($country); } if (!empty($data['status']) && !in_array('status', $ignore)) { $this->setStatus($data['status']); } if (!empty($data['favIcon']) && !in_array('favIcon', $ignore)) { $this->setFavIcon($data['favIcon']); } if (!empty($data['loginPage']) && !in_array('loginPage', $ignore)) { $this->setLoginPage($data['loginPage']); } if (!empty($data['notAuthorizedPage']) && !in_array('notAuthorizedPage', $ignore)) { $this->setNotAuthorizedPage($data['notAuthorizedPage']); } if (!empty($data['notFoundPage']) && !in_array('notFoundPage', $ignore)) { $this->setNotFoundPage($data['notFoundPage']); } if (!empty($data['supportedPageTypes']) && !in_array('supportedPageTypes', $ignore)) { $this->setSupportedPageTypes($data['supportedPageTypes']); } }