protected function setUp() { $this->mapper = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Types\\Rlp\\Mapper\\RlpMapper', ['test-mapper'], 'TestMapper'); $this->mapper->expects($this->any())->method('unique')->will($this->returnCallback([$this, 'uniqueCallback'])); $this->mapper->expects($this->any())->method('getUniquePath')->will($this->returnCallback([$this, 'getUniquePathCallback'])); $structureManager = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Compat\\StructureManagerInterface'); $contentTypeManager = $this->getMockForAbstractClass('Sulu\\Component\\Content\\ContentTypeManagerInterface'); $nodeHelper = $this->getMock('Sulu\\Component\\Util\\SuluNodeHelper', [], [], '', false); $this->strategy = new TreeStrategy($this->mapper, new PathCleanup(), $structureManager, $contentTypeManager, $nodeHelper); }
public function testRestore() { $session = $this->sessionManager->getSession(); $rootNode = $session->getNode('/cmf/sulu_io/routes/de'); // create routes for content $this->rlpMapper->save($this->content2, '/news', 'sulu_io', 'de'); $this->rlpMapper->save($this->content1, '/news/news-1', 'sulu_io', 'de'); // FIXME issue: https://github.com/jackalope/jackalope/issues/227 // FIXME pr: https://github.com/jackalope/jackalope/pull/228 // $this->rlpMapper->save($this->content1, '/news/news-1/sub-1', 'sulu_io', 'de'); // $this->rlpMapper->save($this->content1, '/news/news-1/sub-2', 'sulu_io', 'de'); // // $this->rlpMapper->save($this->content1, '/news/news-2', 'sulu_io', 'de'); // $this->rlpMapper->save($this->content1, '/news/news-2/sub-1', 'sulu_io', 'de'); // $this->rlpMapper->save($this->content1, '/news/news-2/sub-2', 'sulu_io', 'de'); $session->save(); // move route $this->rlpMapper->move('/news', '/asdf', 'sulu_io', 'de'); $session->save(); $session->refresh(false); // move route $this->rlpMapper->move('/asdf', '/test', 'sulu_io', 'de'); $session->save(); $session->refresh(false); // load history $result = $this->rlpMapper->loadHistoryByContentUuid($this->content2->getIdentifier(), 'sulu_io', 'de'); $this->assertEquals(2, count($result)); $news = $rootNode->getNode('news'); $news1 = $rootNode->getNode('news/news-1'); $test = $rootNode->getNode('test'); $test1 = $rootNode->getNode('test/news-1'); // before $this->assertTrue($news->getPropertyValue('sulu:history')); $this->assertEquals($test, $news->getPropertyValue('sulu:content')); $this->assertTrue($news1->getPropertyValue('sulu:history')); $this->assertEquals($test1, $news1->getPropertyValue('sulu:content')); $this->assertFalse($test->getPropertyValue('sulu:history')); $this->assertEquals($this->content2, $test->getPropertyValue('sulu:content')); $this->assertFalse($test1->getPropertyValue('sulu:history')); $this->assertEquals($this->content1, $test1->getPropertyValue('sulu:content')); sleep(1); $this->rlpMapper->restoreByPath('/news', 'sulu_io', 'de'); // after $this->assertFalse($news->getPropertyValue('sulu:history')); $this->assertEquals($this->content2, $news->getPropertyValue('sulu:content')); $this->assertTrue($news1->getPropertyValue('sulu:history')); $this->assertEquals($test1, $news1->getPropertyValue('sulu:content')); $this->assertTrue($test->getPropertyValue('sulu:history')); $this->assertEquals($news, $test->getPropertyValue('sulu:content')); $this->assertFalse($test1->getPropertyValue('sulu:history')); $this->assertEquals($this->content1, $test1->getPropertyValue('sulu:content')); // load history $result = $this->rlpMapper->loadHistoryByContentUuid($this->content2->getIdentifier(), 'sulu_io', 'de'); $this->assertEquals(2, count($result)); $this->assertEquals('/test', $result[0]->getResourceLocator()); $this->assertTrue($result[0]->getCreated() > $result[1]->getCreated()); $this->assertEquals('/asdf', $result[1]->getResourceLocator()); }
public function testLoad() { //its a delegate $result = $this->mapper->loadByResourceLocator('/test', 'default', 'de'); $this->assertEquals('this-is-a-uuid', $result); }
/** * restore given resource locator. * * @param string $path of resource locator * @param string $webspaceKey key of portal * @param string $languageCode * @param string $segmentKey */ public function restoreByPath($path, $webspaceKey, $languageCode, $segmentKey = null) { $this->mapper->restoreByPath($path, $webspaceKey, $languageCode, $segmentKey); }