private function initializeContentTypes(OutputInterface $output, WorkspaceInterface $workspace) { $output->writeln(' <info>content node types</>:'); foreach ([new SuluNodeType(), new PathNodeType(), new ContentNodeType(), new SnippetNodeType(), new PageNodeType(), new HomeNodeType()] as $nodeType) { $output->writeln(sprintf(' [*] %s', $nodeType->getName())); $workspace->getNodeTypeManager()->registerNodeType($nodeType, true); } }
public function setUp() { $this->session = $this->prophesize(SessionInterface::class); $this->workspace = $this->prophesize(WorkspaceInterface::class); $this->queryManager = $this->prophesize(QueryManagerInterface::class); $this->dispatcher = $this->prophesize(EventDispatcherInterface::class); $this->phpcrQuery = $this->prophesize(QueryInterface::class); $this->phpcrResult = $this->prophesize(QueryResultInterface::class); $this->queryCreateEvent = $this->prophesize(QueryCreateEvent::class); $this->queryExecuteEvent = $this->prophesize(QueryExecuteEvent::class); $this->query = $this->prophesize(Query::class); $this->subscriber = new QuerySubscriber($this->session->reveal(), $this->dispatcher->reveal()); $this->session->getWorkspace()->willReturn($this->workspace->reveal()); $this->workspace->getQueryManager()->willReturn($this->queryManager->reveal()); }
/** * Test that update has no effect if the source node not found * (from JCR spec 10.8.3: "If this node does not have a corresponding node in srcWorkspace, then the method has no effect."). */ public function testUpdateSrcNotFound() { $srcNode = '/tests_write_manipulation_clone/testWorkspaceUpdateNode/updateSrcNotFound'; $dstNode = $srcNode; $srcSession = $this->srcWs->getSession(); $destSession = self::$destWs->getSession(); self::$destWs->cloneFrom($this->srcWsName, $srcNode, $dstNode, false); $clonedNode = $destSession->getNode($dstNode); $this->assertCount(4, $clonedNode->getProperties()); $this->checkNodeProperty($clonedNode, 'jcr:uuid', '1d392bcb-3e49-4f0e-b0af-7c30ab838122'); $this->checkNodeProperty($clonedNode, 'foo', 'bar_6'); // Update but then remove source node $node = $srcSession->getNode($srcNode); $node->setProperty('foo', 'foo-updated'); $srcSession->removeItem($srcNode); $srcSession->save(); try { $clonedNode->update($this->srcWsName); } catch (\Exception $exception) { $this->fail("'update' method should not raise an error when source not found, got error: " . $exception->getMessage()); } $destSession->refresh(false); // Cloned node should not get any updates that were made to the source node before it was removed $clonedNode = $destSession->getNode($dstNode); $this->assertCount(4, $clonedNode->getProperties()); $this->checkNodeProperty($clonedNode, 'jcr:uuid', '1d392bcb-3e49-4f0e-b0af-7c30ab838122'); $this->checkNodeProperty($clonedNode, 'foo', 'bar_6'); }
public function setUp() { $this->session = $this->getMock('PHPCR\\SessionInterface'); $this->workspace = $this->getMock('PHPCR\\WorkspaceInterface'); $this->repository = $this->getMock('PHPCR\\RepositoryInterface'); $this->queryManager = $this->getMock('PHPCR\\Query\\QueryManagerInterface'); $this->row1 = $this->getMock('PHPCR\\Tests\\Stubs\\MockRow'); $this->node1 = $this->getMock('PHPCR\\Tests\\Stubs\\MockNode'); $this->dumperHelper = $this->getMockBuilder('PHPCR\\Util\\Console\\Helper\\PhpcrConsoleDumperHelper')->disableOriginalConstructor()->getMock(); $this->helperSet = new HelperSet(array('phpcr' => new PhpcrHelper($this->session), 'phpcr_console_dumper' => $this->dumperHelper)); $this->session->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->workspace)); $this->workspace->expects($this->any())->method('getName')->will($this->returnValue('test')); $this->workspace->expects($this->any())->method('getQueryManager')->will($this->returnValue($this->queryManager)); $this->queryManager->expects($this->any())->method('getSupportedQueryLanguages')->will($this->returnValue(array('JCR-SQL2'))); $this->application = new Application(); $this->application->setHelperSet($this->helperSet); }
/** * Verifies that transport::copy actually copies binary data of children nodes */ public function testCopyChildrenBinaryData() { $src = '/tests_write_manipulation_copy/testCopyChildrenBinaryData/srcNode'; $dst = '/tests_write_manipulation_copy/testCopyChildrenBinaryData/dstNode'; $this->ws->copy($src, $dst); $this->session->refresh(true); $srcChild = $this->session->getNode($src . '/data.bin'); $dstChild = $this->session->getNode($dst . '/data.bin'); $srcProp = $srcChild->getProperty('jcr:data'); $dstProp = $dstChild->getProperty('jcr:data'); $this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType()); $this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType()); $srcBin = $srcProp->getBinary(); $dstBin = $dstProp->getBinary(); $this->assertTrue(is_resource($srcBin), 'Failed to get src binary stream'); $this->assertTrue(is_resource($dstBin), 'Failed to get dst binary stream'); $this->assertEquals(stream_get_contents($srcBin), stream_get_contents($dstBin)); }
/** * Verifies that transport::copy actually copies binary data of children nodes * Multivalue test */ public function testCopyChildrenBinaryDataMultivalue() { $src = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/srcNode'; $dst = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/dstNode'; $this->ws->copy($src, $dst); $this->session->refresh(true); //Multivalue $srcProp = $this->session->getNode($src . '/multiple')->getProperty('jcr:data'); $dstProp = $this->session->getNode($dst . '/multiple')->getProperty('jcr:data'); $this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType()); $this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType()); $srcVal = $srcProp->getValue(); $dstVal = $dstProp->getValue(); $this->assertTrue(is_array($srcVal), 'Failed to get src value'); $this->assertTrue(is_array($dstVal), 'Failed to get dst value'); $this->assertTrue(is_resource($srcVal[0])); $this->assertTrue(is_resource($srcVal[1])); $this->assertTrue(is_resource($dstVal[0])); $this->assertTrue(is_resource($dstVal[1])); $this->assertEquals(stream_get_contents($srcVal[0]), stream_get_contents($dstVal[0])); $this->assertEquals(stream_get_contents($srcVal[1]), stream_get_contents($dstVal[1])); }
public function testVariantNamespaceRegistered() { $nr = $this->workspace->getNamespaceRegistry(); $this->assertEquals(Translation::LOCALE_NAMESPACE_URI, $nr->getURI(Translation::LOCALE_NAMESPACE)); }
public function testGetAccessibleWorkspaceNames() { $names = $this->workspace->getAccessibleWorkspaceNames(); $this->assertInternalType('array', $names); $this->assertContains(self::$loader->getWorkspaceName(), $names); }