protected function setUp()
 {
     parent::setUp();
     $this->matcherFactoryMock = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Matcher\\MatcherFactoryInterface');
     $this->configResolverMock = $this->getMock('eZ\\Publish\\Core\\MVC\\ConfigResolverInterface');
     $this->contentServiceMock = $this->getMock('eZ\\Publish\\API\\Repository\\ContentService');
     $this->contentServiceMock->expects($this->any())->method('loadContentByContentInfo')->will($this->returnValue(new Content()));
 }
 public function testGetTranslatedNameByContentInfoForcedLanguageMainLanguage()
 {
     $name = 'Name in main language';
     $mainLanguage = 'eng-GB';
     $contentInfo = new ContentInfo(array('id' => 123, 'mainLanguageCode' => $mainLanguage, 'name' => $name));
     $this->configResolver->expects($this->never())->method('getParameter');
     $this->contentService->expects($this->never())->method('loadContentByContentInfo');
     $this->assertSame($name, $this->translationHelper->getTranslatedContentNameByContentInfo($contentInfo, $mainLanguage));
 }
 public function testLoadBlock()
 {
     $contentId = 12;
     $blockId = 'abc0123';
     $block = new Block(array('id' => $blockId));
     $zone = new Zone(array('blocks' => array($block)));
     $page = new Page(array('zones' => array($zone)));
     $value = new Value($page);
     $field = new Field(array('value' => $value));
     $content = new Content(array('internalFields' => array($field)));
     $this->pageService->setStorageGateway($this->storageGateway);
     $this->storageGateway->expects($this->once())->method('getContentIdByBlockId')->with($blockId)->will($this->returnValue($contentId));
     $this->contentService->expects($this->once())->method('loadContent')->with($contentId)->will($this->returnValue($content));
     // Calling assertion twice to test cache (comes along with storage gateway's
     // getLocationIdByBlockId() that should be called only once. See above)
     $this->assertSame($block, $this->pageService->loadBlock($blockId));
     $this->assertSame($block, $this->pageService->loadBlock($blockId));
 }