Beispiel #1
0
 public function test_pageDataInitializedOnlyOnce()
 {
     // ARRANGE
     $pageId = 'PAGE-render00-test-api0-page-000000000001-PAGE';
     $pageItem = new NavigationInfoStorageItem($pageId, 'page_type_id', 'title', 'description', time() - 3600, true, 'navigationTitle', array('PARENT_ID_1', 'PARENT_ID_2'), array('CHILD_1', 'CHILD_2', 'CHILD_3'), 'MDB_ID_1');
     $callCount = 0;
     $infoStorageMock = $this->createNavigationInfoStorageMock();
     $infoStorageMock->expects($this->atLeastOnce())->method('getItem')->with($this->equalTo($pageId))->will($this->returnCallback(function ($pageId) use(&$pageItem, &$callCount) {
         $callCount++;
         return $pageItem;
     }));
     $infoStorageMock->expects($this->atLeastOnce())->method('getPageUrl')->with($this->equalTo($pageId))->will($this->returnValue('/url/' . $pageId));
     $infoStorageMock->expects($this->atLeastOnce())->method('getPageGlobals')->with($this->equalTo($pageId))->will($this->returnValue(array()));
     // ACT
     $page = new Page($infoStorageMock, $pageId);
     // ASSERT
     $this->assertInstanceOf('Render\\APIs\\APIv1\\Page', $page);
     $this->assertEquals(0, $callCount, "Failed asserting that \$infoStorage->getItem() doesn't called at this time");
     $this->assertEquals($pageId, $page->getPageId());
     $this->assertEquals(0, $callCount, "Failed asserting that \$infoStorage->getItem() doesn't called at this time");
     $this->assertEquals('/url/' . $pageId, $page->getUrl());
     $this->assertEquals(0, $callCount, "Failed asserting that \$infoStorage->getItem() doesn't called at this time");
     $this->assertNull($page->getGlobal('teaserTitle'));
     $this->assertEquals(0, $callCount, "Failed asserting that \$infoStorage->getItem() doesn't called at this time");
     $this->assertEquals($pageItem->getTitle(), $page->getTitle());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getDescription(), $page->getDescription());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getDate(), $page->getDate());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->showInNavigation(), $page->showInNavigation());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getNavigationTitle(), $page->getNavigationTitle());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getNavigationTitle(), $page->getNavigationTitle(false));
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getParentIds(), $page->getParentIds());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getChildrenIds(), $page->getChildrenIds());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
     $this->assertEquals($pageItem->getMediaId(), $page->getMediaId());
     $this->assertEquals(1, $callCount, "Failed asserting that \$infoStorage->getItem() only called once at this time");
 }
 /**
  * @param NavigationInfoStorageItem $expectedItem
  * @param NavigationInfoStorageItem $actualItem
  */
 protected function assertNavigationItemEquals(NavigationInfoStorageItem $expectedItem, NavigationInfoStorageItem $actualItem)
 {
     $this->assertSame($expectedItem->getPageId(), $actualItem->getPageId(), "Assertion for NavigationStorageItem::getPageId:");
     $this->assertSame($expectedItem->getPageType(), $actualItem->getPageType(), "Assertion for NavigationStorageItem::getPageType:");
     $this->assertSame($expectedItem->getTitle(), $actualItem->getTitle(), "Assertion for NavigationStorageItem::getTitle:");
     $this->assertSame($expectedItem->getDescription(), $actualItem->getDescription(), "Assertion for NavigationStorageItem::getDescription:");
     $this->assertSame($expectedItem->getDate(), $actualItem->getDate(), "Assertion for NavigationStorageItem::getDate:");
     $this->assertSame($expectedItem->showInNavigation(), $actualItem->showInNavigation(), "Assertion for NavigationStorageItem::showInNavigation:");
     $this->assertSame($expectedItem->getNavigationTitle(), $actualItem->getNavigationTitle(), "Assertion for NavigationStorageItem::getNavigationTitle:");
     $this->assertSame($expectedItem->getMediaId(), $actualItem->getMediaId(), "Assertion for NavigationStorageItem::getMediaId:");
     $this->assertEquals($expectedItem->getParentIds(), $actualItem->getParentIds(), "Assertion for NavigationStorageItem::getParentIds:");
     $this->assertEquals($expectedItem->getChildrenIds(), $actualItem->getChildrenIds(), "Assertion for NavigationStorageItem::getChildrenIds:");
 }