public function testGetPreviewLocationNoLocation() { $contentId = 123; $contentInfo = $this->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo')->setConstructorArgs(array(array('id' => $contentId)))->getMockForAbstractClass(); $this->contentService->expects($this->once())->method('loadContentInfo')->with($contentId)->will($this->returnValue($contentInfo)); $this->locationHandler->expects($this->once())->method('loadParentLocationsForDraftContent')->with($contentId)->will($this->returnValue(array())); $this->locationHandler->expects($this->never())->method('loadLocation'); $this->assertNull($this->provider->loadMainLocation($contentId)); }
/** * Tests the LocationCreateStruct visitor. * * @return string */ public function testVisit() { $visitor = $this->getVisitor(); $generator = $this->getGenerator(); $generator->startDocument(null); $locationCreateStruct = new LocationCreateStruct(); $locationCreateStruct->hidden = false; $locationCreateStruct->parentLocationId = 42; $locationCreateStruct->priority = 0; $locationCreateStruct->remoteId = 'remote-id'; $locationCreateStruct->sortField = Location::SORT_FIELD_PATH; $locationCreateStruct->sortOrder = Location::SORT_ORDER_ASC; $this->locationServiceMock->expects($this->once())->method('loadLocation')->with(42)->will($this->returnValue(new Location(['pathString' => '/1/2/42']))); $this->getRouterMock()->expects($this->once())->method('generate')->with('ezpublish_rest_loadLocation', ['locationPath' => '1/2/42'])->will($this->returnValue('/content/locations/1/2/42')); $visitor->visit($this->getVisitorMock(), $generator, $locationCreateStruct); $result = $generator->endDocument(null); $this->assertNotNull($result); return $result; }