/** * @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()); }
/** * 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)); }