/** * @covers \Magento\Cms\Model\Page::checkIdentifier */ public function testCheckIdentifier() { $identifier = 1; $storeId = 2; $fetchOneResult = 'some result'; $this->resourcePageMock->expects($this->atLeastOnce())->method('checkIdentifier')->with($identifier, $storeId)->willReturn($fetchOneResult); $this->assertInternalType('string', $this->thisMock->checkIdentifier($identifier, $storeId)); }
/** * @test * * @expectedException \Magento\Framework\Exception\NoSuchEntityException */ public function testGetByIdException() { $pageId = '123'; $this->page->expects($this->once())->method('getId')->willReturn(false); $this->pageResource->expects($this->once())->method('load')->with($this->page, $pageId)->willReturn($this->page); $this->repository->getById($pageId); }
public function testGetLabelByPageId() { $pageId = 1; $label = 'Label by page id'; $this->mockResourcePage->expects($this->once())->method('getCmsPageTitleById')->with($pageId)->willReturn($label); $this->linkElement->setData('page_id', $pageId); $this->assertEquals($label, $this->linkElement->getLabel()); }
/** * Delete Page * * @param Data\PageInterface $page * @return bool * @throws CouldNotDeleteException */ public function delete(Data\PageInterface $page) { try { $this->resource->delete($page); } catch (\Exception $exception) { throw new CouldNotDeleteException(__($exception->getMessage())); } return true; }
/** * Run test deleteById method * * @return void */ public function testDeleteById() { $id = 20; $pageMock = $this->getMockForAbstractClass('Magento\\Cms\\Model\\Page', [], '', false, true, true, ['getId']); $this->pageFactoryMock->expects($this->once())->method('create')->will($this->returnValue($pageMock)); $this->resourceMock->expects($this->once())->method('load')->with($pageMock, $id); $pageMock->expects($this->once())->method('getId')->will($this->returnValue($id)); $this->resourceMock->expects($this->once())->method('delete')->with($pageMock); $this->assertTrue($this->pageRepository->deleteById($id)); }
/** * Prepare label using passed text as parameter. * If anchor text was not specified use title instead and * if title will be blank string, page identifier will be used. * * @return string */ public function getLabel() { if ($this->getData('anchor_text')) { $this->_anchorText = $this->getData('anchor_text'); } elseif ($this->getTitle()) { $this->_anchorText = $this->getTitle(); } elseif ($this->getData('href')) { $this->_anchorText = $this->_resourcePage->setStore($this->_storeManager->getStore())->getCmsPageTitleByIdentifier($this->getData('href')); } elseif ($this->getData('page_id')) { $this->_anchorText = $this->_resourcePage->getCmsPageTitleById($this->getData('page_id')); } else { $this->_anchorText = $this->getData('href'); } return $this->_anchorText; }