/**
  * 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']);
 }
Beispiel #2
0
 /**
  * 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);
 }
 /**
  * Setup for tests
  *
  * @return null
  */
 public function setUp()
 {
     $this->mockUserService = $this->getMockBuilder('RcmUser\\Service\\RcmUserService')->disableOriginalConstructor()->getMock();
     $this->currentSite = new Site();
     $this->currentSite->setSiteId(1);
     $this->mockCmsPermissionCheck = $this->getMockBuilder('\\Rcm\\Acl\\CmsPermissionChecks')->disableOriginalConstructor()->getMock();
     $this->mockAclService = $this->getMockBuilder('\\RcmUser\\Acl\\Service\\AclDataService')->disableOriginalConstructor()->getMock();
     $result = new Result();
     $this->mockAclService->expects($this->any())->method('getRulesByResource')->will($this->returnValue($result));
     $this->mockAclService->expects($this->any())->method('getAllRoles')->will($this->returnValue($result));
     $userService = $this->mockUserService;
     $config = $this->getConfig();
     /** @var \RcmUser\Service\RcmUserService $userService */
     $this->controller = new AdminPanelController($config, $this->currentSite, $this->mockCmsPermissionCheck);
     $event = new MvcEvent();
     $routeMatch = new RouteMatch(['page' => 'index', 'pageType' => 'n']);
     $event->setRouteMatch($routeMatch);
     $this->controller->setEvent($event);
 }
Beispiel #4
0
 /**
  * Test Check Domain Return 404 if not found.
  *
  * @return void
  *
  * @covers \Rcm\EventListener\RouteListener
  */
 public function testCheckDomainReturnsNotFound()
 {
     $serverParams = new Parameters(['HTTP_HOST' => 'not.found.com']);
     $this->currentSite->setDomain(new Domain());
     $this->currentSite->setSiteId(null);
     $request = new Request();
     $request->setServer($serverParams);
     $event = new MvcEvent();
     $event->setRequest($request);
     $actual = $this->routeListener->checkDomain($event);
     $this->assertTrue($actual instanceof Response);
     $responseCode = $actual->getStatusCode();
     $this->assertEquals(404, $responseCode);
 }
 /**
  * testGets
  *
  * @return void
  */
 public function testGets()
 {
     $currentSite = new Site();
     $currentSite->setSiteId(321);
     $default = 'DEFAULT';
     $defCase = $this->getTestCase('_default');
     $unit = new RcmGoogleAnalytics($this->getMockEntityManger($defCase), $currentSite);
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getSiteAnalyticEntity($currentSite, $default));
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getCurrentAnalyticEntity($default));
     $this->assertInstanceOf('\\Reliv\\RcmGoogleAnalytics\\Entity\\RcmGoogleAnalytics', $unit->getCurrentAnalyticEntityWithVerifyCode($defCase['entity']['verificationCode']));
     $this->assertEquals($default, $unit->getCurrentAnalyticEntityWithVerifyCode('nope', $default));
     $unit = new RcmGoogleAnalytics($this->getMockEntityManger($this->getTestCase('case1')), $currentSite);
     $this->assertEquals($default, $unit->getSiteAnalyticEntity($currentSite, $default));
 }
 /**
  * Generic test for the constructor
  *
  * @return null
  * @covers \Rcm\Factory\ContainerViewHelperFactory
  */
 public function testCreateService()
 {
     $mockPluginManager = $this->getMockBuilder('\\Rcm\\Service\\PluginManager')->disableOriginalConstructor()->getMock();
     $mockEntityManager = $this->getMockBuilder('\\Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $mockContainerRepo = $this->getMockBuilder('\\Rcm\\Repository\\Container')->disableOriginalConstructor()->getMock();
     $mockEntityManager->expects($this->any())->method('getRepository')->will($this->returnValue($mockContainerRepo));
     $site = new Site();
     $site->setSiteId(1);
     $sm = new ServiceManager();
     $sm->setService('Doctrine\\ORM\\EntityManager', $mockEntityManager);
     $sm->setService('Rcm\\Service\\PluginManager', $mockPluginManager);
     $sm->setService('Rcm\\Service\\CurrentSite', $site);
     $helperManager = new HelperPluginManager();
     $helperManager->setServiceLocator($sm);
     $factory = new ContainerViewHelperFactory();
     $object = $factory->createService($helperManager);
     $this->assertTrue($object instanceof Container);
 }
Beispiel #7
0
 /**
  * Test Set Site Layout
  *
  * @return void
  *
  * @covers \Rcm\EventListener\DispatchListener
  */
 public function testSetSiteLayout()
 {
     $favicon = 'someFavicon';
     $title = 'My Site Title';
     $layout = 'myLayout';
     $mockLayoutManager = $this->getMockBuilder('Rcm\\Service\\LayoutManager')->disableOriginalConstructor()->getMock();
     $mockLayoutManager->expects($this->any())->method('getSiteLayout')->will($this->returnValue($layout));
     $currentSite = new Site();
     $currentSite->setSiteId(1);
     $currentSite->setFavIcon($favicon);
     $currentSite->setSiteTitle($title);
     $currentSite->setSiteLayout($layout);
     $testCase = [['Rcm\\Service\\LayoutManager', $mockLayoutManager], ['Rcm\\Service\\CurrentSite', $currentSite]];
     // Zend\ServiceManager\ServiceLocatorInterface
     $mockServiceLocator = $this->getMockBuilder('\\Zend\\ServiceManager\\ServiceLocatorInterface')->disableOriginalConstructor()->getMock();
     $mockServiceLocator->expects($this->any())->method('get')->will($this->returnValueMap($testCase));
     $listener = new DispatchListener($mockServiceLocator);
     $event = new MvcEvent();
     $listener->setSiteLayout($event);
     $view = $event->getViewModel();
     $template = $view->getTemplate();
     $this->assertEquals('layout/' . $layout, $template);
 }
 /**
  * create - Create a site
  *
  * @param array $data
  *
  * @return mixed|JsonModel
  */
 public function create($data)
 {
     /* ACCESS CHECK */
     if (!$this->rcmIsAllowed('sites', 'admin')) {
         $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
         return $this->getResponse();
     }
     /* */
     $inputFilter = new SiteInputFilter();
     $inputFilter->setData($data);
     if (!$inputFilter->isValid()) {
         return new ApiJsonModel([], 1, 'Some values are missing or invalid.', $inputFilter->getMessages());
     }
     $data = $inputFilter->getValues();
     $siteManager = $this->getSiteManager();
     try {
         $data = $siteManager->prepareSiteData($data);
         /** @var \Rcm\Repository\Domain $domainRepo */
         $domainRepo = $this->getEntityManager()->getRepository('\\Rcm\\Entity\\Domain');
         $data['domain'] = $domainRepo->createDomain($data['domainName']);
     } catch (\Exception $e) {
         return new ApiJsonModel(null, 1, $e->getMessage());
     }
     /** @var \Rcm\Entity\Site $newSite */
     $newSite = new Site();
     $newSite->populate($data);
     // make sure we don't have a siteId
     $newSite->setSiteId(null);
     try {
         $newSite = $siteManager->createSite($newSite);
     } catch (\Exception $e) {
         return new ApiJsonModel(null, 1, $e->getMessage());
     }
     return new ApiJsonModel($newSite, 0, 'Success');
 }
Beispiel #9
0
 /**
  * Test Clone
  *
  * @return void
  *
  * @covers \Rcm\Entity\Page
  */
 public function testClone()
 {
     $site = new Site();
     $site->setSiteId(55);
     $container = ['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' => 44, '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' => 46, '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' => 48, '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' => 50, 'plugin' => 'MockPlugin4', 'siteWide' => true, 'displayName' => 'TestSiteWide2', 'instanceConfig' => ['var3' => 3, 'var4' => 4], 'md5' => 'secondMd5']]]]]];
     $this->page->setPageId($container['pageId']);
     $this->page->setName($container['name']);
     $this->page->setAuthor($container['author']);
     $this->page->setCreatedDate($container['createdDate']);
     $this->page->setLastPublished($container['lastPublished']);
     $this->page->setSite($site);
     foreach ($container['revisions'] as $index => $revisionData) {
         $revision = new Revision();
         $revision->setRevisionId($revisionData['revisionId']);
         $revision->setAuthor($revisionData['author']);
         $revision->setCreatedDate($revisionData['createdDate']);
         $revision->publishRevision();
         $revision->setPublishedDate($revisionData['publishedDate']);
         $revision->setMd5($revisionData['md5']);
         foreach ($revisionData['instances'] as $instance) {
             $plugin = new PluginInstance();
             $plugin->setInstanceId($instance['instance']['pluginInstanceId']);
             $plugin->setPlugin($instance['instance']['plugin']);
             if ($instance['instance']['siteWide']) {
                 $plugin->setSiteWide();
             }
             $plugin->setDisplayName($instance['instance']['displayName']);
             $plugin->setInstanceConfig($instance['instance']['instanceConfig']);
             $plugin->setMd5($instance['instance']['md5']);
             $wrapper = new PluginWrapper();
             $wrapper->setPluginWrapperId($instance['pluginWrapperId']);
             $wrapper->setLayoutContainer($instance['layoutContainer']);
             $wrapper->setRenderOrderNumber($instance['renderOrder']);
             $wrapper->setHeight($instance['height']);
             $wrapper->setWidth($instance['width']);
             $wrapper->setDivFloat($instance['divFloat']);
             $wrapper->setInstance($plugin);
             $revision->addPluginWrapper($wrapper);
         }
         if ($index === 0) {
             $this->page->setPublishedRevision($revision);
         } elseif ($index === 1) {
             $this->page->setStagedRevision($revision);
         }
         $this->page->addRevision($revision);
     }
     $this->assertCount(2, $this->page->getRevisions());
     $clonedContainer = clone $this->page;
     /* Test Container */
     $this->assertNotEquals($this->page->getPageId(), $clonedContainer->getPageId());
     $this->assertNull($clonedContainer->getPageId());
     $this->assertNull($clonedContainer->getPublishedRevision());
     $this->assertCount(1, $clonedContainer->getRevisions());
     $containerName = $clonedContainer->getName();
     $containerIsempty = empty($containerName);
     $this->assertTrue($containerIsempty);
     $this->assertNull($clonedContainer->getParent());
     $currentRevision = $this->page->getPublishedRevision();
     $clonedCurrentRev = $clonedContainer->getStagedRevision();
     /* Test Revision */
     $this->assertNotEquals($currentRevision->getRevisionId(), $clonedCurrentRev->getRevisionId());
     $this->assertNull($clonedCurrentRev->getRevisionId());
     $this->assertEquals($currentRevision->getAuthor(), $clonedCurrentRev->getAuthor());
     $this->assertNotEquals($currentRevision->getCreatedDate(), $clonedCurrentRev->getCreatedDate());
     $this->assertFalse($clonedCurrentRev->wasPublished());
     $this->assertEquals($currentRevision->getMd5(), $clonedCurrentRev->getMd5());
     $revisionWrappers = $currentRevision->getPluginWrappers();
     $clonedWrappers = $clonedCurrentRev->getPluginWrappers();
     $this->assertNotEquals($revisionWrappers, $clonedWrappers);
     /** @var \Rcm\Entity\PluginWrapper $clonedWrapper */
     foreach ($clonedWrappers as $clonedWrapper) {
         if (!$clonedWrapper->getInstance()->isSiteWide()) {
             $this->assertNull($clonedWrapper->getInstance()->getInstanceId());
         } else {
             $this->assertNotNull($clonedWrapper->getInstance()->getInstanceId());
         }
     }
     $page = new Page();
     $clone = clone $page;
     $this->assertInstanceOf('\\Rcm\\Entity\\Page', $clone);
 }
Beispiel #10
0
 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']);
 }
Beispiel #11
0
 /**
  * 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());
         }
     }
 }
Beispiel #12
0
 /**
  * Test Set Page Type
  *
  * @return void
  *
  */
 public function testSetSiteId()
 {
     $reflectedClass = new \ReflectionClass($this->validator);
     $reflectedProp = $reflectedClass->getProperty('site');
     $reflectedProp->setAccessible(true);
     $defaultValue = $reflectedProp->getValue($this->validator);
     $this->assertEquals(1, $defaultValue->getSiteId());
     $site = new Site();
     $site->setSiteId(22);
     $this->validator->setSite($site);
     $result = $reflectedProp->getValue($this->validator);
     $this->assertEquals(22, $result->getSiteId());
 }
Beispiel #13
0
 /**
  * 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;
 }