예제 #1
0
 /**
  * @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));
 }
예제 #2
0
 /**
  * @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);
 }
예제 #3
0
파일: LinkTest.php 프로젝트: nja78/magento2
 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());
 }
예제 #4
0
 /**
  * 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));
 }