Esempio n. 1
0
 protected function createNode($id, $username)
 {
     $repository = $this->getMockBuilder('Jackalope\\Repository')->disableOriginalConstructor()->getMock();
     $this->session->expects($this->any())->method('getRepository')->with()->will($this->returnValue($repository));
     $nodeData = array("jcr:primaryType" => "rep:root", "jcr:system" => array(), 'username' => $username);
     return new Node($this->factory, $nodeData, $id, $this->session, $this->objectManager);
 }
Esempio n. 2
0
 private function migrateExternalLinks(SessionInterface $session, $directionUp = true)
 {
     $workspace = $session->getWorkspace();
     $queryManager = $workspace->getQueryManager();
     $webspaceManager = $this->container->get('sulu_core.webspace.webspace_manager');
     $propertyEncoder = $this->container->get('sulu_document_manager.property_encoder');
     $webspaces = $webspaceManager->getWebspaceCollection();
     /** @var Webspace $webspace */
     foreach ($webspaces as $webspace) {
         foreach ($webspace->getAllLocalizations() as $localization) {
             $locale = $localization->getLocalization();
             $query = $queryManager->createQuery(sprintf('SELECT * FROM [nt:base] WHERE [%s] = 4 AND [jcr:mixinTypes] = "sulu:page"', $propertyEncoder->localizedSystemName('nodeType', $locale)), 'JCR-SQL2');
             $rows = $query->execute();
             foreach ($rows as $row) {
                 /** @var NodeInterface $node */
                 $node = $row->getNode();
                 $templatePropertyName = $propertyEncoder->localizedSystemName('template', $locale);
                 try {
                     if (true === $directionUp) {
                         $node->setProperty($templatePropertyName, $webspace->getDefaultTemplate('page'));
                     } else {
                         $node->setProperty($templatePropertyName, 'external-link');
                     }
                 } catch (\Exception $e) {
                     echo $e->getMessage() . PHP_EOL;
                 }
             }
         }
     }
 }
 public function testCommand()
 {
     $this->converter->expects($this->once())->method('convert')->with('Document\\MyClass', array('en'), array(), 'none')->will($this->returnValue(false));
     $this->mockSession->expects($this->once())->method('save');
     $this->commandTester->execute(array('classname' => 'Document\\MyClass', '--locales' => array('en'), '--force' => true));
     $this->assertEquals('.' . PHP_EOL . 'done' . PHP_EOL, $this->commandTester->getDisplay());
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $webspaceKey = $input->getArgument('webspaceKey');
     $locale = $input->getArgument('locale');
     $basePath = $input->getOption('base-path');
     $dryRun = $input->getOption('dry-run');
     $this->session = $this->getContainer()->get('doctrine_phpcr')->getManager()->getPhpcrSession();
     $this->sessionManager = $this->getContainer()->get('sulu.phpcr.session');
     $this->output = $output;
     $path = $this->sessionManager->getRoutePath($webspaceKey, $locale);
     $relativePath = $basePath !== null ? '/' . ltrim($basePath, '/') : '/';
     $fullPath = rtrim($path . $relativePath, '/');
     if (!$this->session->nodeExists($fullPath)) {
         $this->output->write('<error>Resource-Locator "' . $relativePath . '" not found</error>');
         return;
     }
     $node = $this->session->getNode($fullPath);
     $this->cleanup($node, $path, $dryRun);
     if (false === $dryRun) {
         $this->output->writeln('<info>Saving ...</info>');
         $this->session->save();
         $this->output->writeln('<info>Done</info>');
     } else {
         $this->output->writeln('<info>Dry run complete</info>');
     }
 }
 public function setUp()
 {
     $this->factory = $this->getMock('Jackalope\\FactoryInterface');
     $this->session = $this->getSessionMock();
     $this->session->expects($this->any())->method('getNodes')->will($this->returnValue(array()));
     $this->session->expects($this->any())->method('getNodesByIdentifier')->will($this->returnValue(array()));
     $this->eventFilter = new EventFilter($this->factory, $this->session);
 }
Esempio n. 6
0
 /**
  * {@inheritDoc}
  */
 protected function getNode(array $pathSegments)
 {
     $absPath = '/' . implode('/', $pathSegments);
     try {
         return $this->session->getNode($absPath);
     } catch (\PHPCR\PathNotFoundException $e) {
         return null;
     }
 }
Esempio n. 7
0
 public function __construct(SessionManagerInterface $sessionManager, PropertyEncoder $propertyEncoder, WebspaceManagerInterface $webspaceManager, LocalizationFinderInterface $localizationFinder, SuluNodeHelper $nodeHelper)
 {
     $this->sessionManager = $sessionManager;
     $this->propertyEncoder = $propertyEncoder;
     $this->webspaceManager = $webspaceManager;
     $this->localizationFinder = $localizationFinder;
     $this->nodeHelper = $nodeHelper;
     $this->session = $sessionManager->getSession();
     $this->qomFactory = $this->session->getWorkspace()->getQueryManager()->getQOMFactory();
 }
Esempio n. 8
0
    /**
     * Register the system node types on the given session.
     *
     * @param SessionInterface
     */
    public function registerNodeTypes(SessionInterface $session)
    {
        $cnd = <<<CND
// register phpcr_locale namespace
<{$this->localeNamespace}='{$this->localeNamespaceUri}'>
// register phpcr namespace
<{$this->phpcrNamespace}='{$this->phpcrNamespaceUri}'>
[phpcr:managed]
mixin
- phpcr:class (STRING)
- phpcr:classparents (STRING) multiple
CND;
        $nodeTypeManager = $session->getWorkspace()->getNodeTypeManager();
        $nodeTypeManager->registerNodeTypesCnd($cnd, 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());
 }
Esempio n. 10
0
 private function upgradeLocale(Webspace $webspace, Localization $localization, OutputInterface $output)
 {
     $output->writeln('  > Upgrade Locale: ' . $localization->getLocalization('-'));
     $contentNode = $this->liveSession->getNode($this->sessionManager->getContentPath($webspace->getKey()));
     $this->upgradeNode($contentNode, $webspace, $localization, $output);
     $this->upgradeByParent($contentNode, $webspace, $localization, $output);
 }
 private function initPages()
 {
     $this->team = $this->savePage('simple', ['title' => 'Team', 'url' => '/team'], $this->session->getNode('/cmf/sulu_io/contents')->getIdentifier());
     $this->johannes = $this->savePage('simple', ['title' => 'Johannes', 'url' => '/team/johannes'], $this->team->getUuid(), [$this->tag1->getId()]);
     $this->daniel = $this->savePage('simple', ['title' => 'Daniel', 'url' => '/team/daniel'], $this->team->getUuid());
     $this->thomas = $this->savePage('simple', ['title' => 'Thomas', 'url' => '/team/thomas'], $this->team->getUuid());
 }
Esempio n. 12
0
 /**
  * {@inheritDoc}
  */
 public function transactional($callback)
 {
     if (!is_callable($callback)) {
         throw new InvalidArgumentException(sprintf('Parameter $callback must be a valid callable, "%s" given', gettype($callback)));
     }
     $transactionManager = null;
     try {
         $transactionManager = $this->session->getWorkspace()->getTransactionManager();
     } catch (UnsupportedRepositoryOperationException $e) {
         $result = call_user_func($callback, $this);
         $this->flush();
         return $result;
     }
     $transactionManager->begin();
     try {
         $result = call_user_func($callback, $this);
         $this->flush();
     } catch (\Exception $exception) {
         $this->close();
         $transactionManager->rollback();
         throw $exception;
     }
     $transactionManager->commit();
     return $result;
 }
Esempio n. 13
0
 /**
  * Check whether the repository supports this descriptor and skip the test if it is not supported.
  *
  * @param string $descriptor
  *
  * @return bool True if the test can be done. Otherwise the test is skipped.
  */
 protected function skipIfNotSupported($descriptor)
 {
     if (false === $this->session->getRepository()->getDescriptor($descriptor)) {
         $this->markTestSkipped('Descriptor "' . $descriptor . '" not supported');
     }
     return true;
 }
Esempio n. 14
0
 /**
  * Delete all content in the workspace this session is bound to.
  *
  * Remember to save the session after calling the purge method.
  *
  * Note that if you want to delete a node under your root node, you can just
  * use the remove method on that node. This method is just here to help you
  * because the implementation might add nodes like jcr:system to the root
  * node which you are not allowed to remove.
  *
  * @param SessionInterface $session the session to remove all children of
  *      the root node
  *
  * @see isSystemItem
  */
 public static function purgeWorkspace(SessionInterface $session)
 {
     $root = $session->getRootNode();
     /** @var $property PropertyInterface */
     foreach ($root->getProperties() as $property) {
         if (!self::isSystemItem($property)) {
             $property->remove();
         }
     }
     /** @var $node NodeInterface */
     foreach ($root->getNodes() as $node) {
         if (!self::isSystemItem($node)) {
             $node->remove();
         }
     }
 }
Esempio n. 15
0
 protected function setUp()
 {
     parent::setUp();
     $this->contentMapper = $this->prophesize('Sulu\\Component\\Content\\Mapper\\ContentMapperInterface');
     $this->requestAnalyzer = $this->prophesize('Sulu\\Component\\Webspace\\Analyzer\\RequestAnalyzerInterface');
     $this->contentTypeManager = $this->prophesize('Sulu\\Component\\Content\\ContentTypeManagerInterface');
     $this->structureManager = $this->prophesize('Sulu\\Component\\Content\\Compat\\StructureManagerInterface');
     $this->sessionManager = $this->prophesize('Sulu\\Component\\PHPCR\\SessionManager\\SessionManagerInterface');
     $this->session = $this->prophesize('PHPCR\\SessionInterface');
     $this->node = $this->prophesize('PHPCR\\NodeInterface');
     $this->parentNode = $this->prophesize('PHPCR\\NodeInterface');
     $this->startPageNode = $this->prophesize('PHPCR\\NodeInterface');
     $webspace = new Webspace();
     $webspace->setKey('sulu_test');
     $locale = new Localization();
     $locale->setCountry('us');
     $locale->setLanguage('en');
     $this->requestAnalyzer->getWebspace()->willReturn($webspace);
     $this->requestAnalyzer->getCurrentLocalization()->willReturn($locale);
     $this->contentTypeManager->get('text_line')->willReturn(new TextLine(''));
     $this->sessionManager->getSession()->willReturn($this->session->reveal());
     $this->sessionManager->getContentNode('sulu_test')->willReturn($this->startPageNode->reveal());
     $this->session->getNodeByIdentifier('123-123-123')->willReturn($this->node->reveal());
     $this->session->getNodeByIdentifier('321-321-321')->willReturn($this->parentNode->reveal());
     $this->node->getIdentifier()->willReturn('123-123-123');
     $this->node->getParent()->willReturn($this->parentNode->reveal());
     $this->node->getDepth()->willReturn(4);
     $this->parentNode->getIdentifier()->willReturn('321-321-321');
     $this->parentNode->getDepth()->willReturn(3);
     $this->startPageNode->getDepth()->willReturn(3);
     $this->structureResolver = new StructureResolver($this->contentTypeManager->reveal(), $this->structureManager->reveal());
 }
Esempio n. 16
0
 /**
  * Check whether stream was already loaded, otherwise fetch from backend
  * and cache it.
  *
  * Multivalued properties have a special handling since the backend returns
  * all streams in a single call.
  *
  * Always checks if the current session is still alive.
  *
  * @throws LogicException when trying to use a stream from a closed session
  *      and on trying to access a nonexisting multivalue id.
  *
  * @return void
  */
 private function init_stream()
 {
     if (null === $this->stream) {
         if ($this->session && !$this->session->isLive()) {
             throw new LogicException("Trying to read a stream from a closed transport.");
         }
         $url = parse_url($this->path);
         $this->session = Session::getSessionFromRegistry($url['host']);
         $property_path = $url['path'];
         $token = isset($url['user']) ? $url['user'] : null;
         if (null === $token) {
             $this->stream = $this->session->getObjectManager()->getBinaryStream($property_path);
         } else {
             // check if streams have been loaded for multivalued properties
             if (!isset(self::$multiValueMap[$token])) {
                 self::$multiValueMap[$token] = $this->session->getObjectManager()->getBinaryStream($property_path);
             }
             $index = isset($url['port']) ? $url['port'] - 1 : 0;
             if (!isset(self::$multiValueMap[$token][$index])) {
                 throw new LogicException("Trying to read a stream from a non existant token '{$token}' or token index '{$index}'.");
             }
             $this->stream = self::$multiValueMap[$token][$index];
         }
     }
 }
Esempio n. 17
0
 public function testPostTree()
 {
     $data1 = ['title' => 'news', 'tags' => ['tag1', 'tag2'], 'url' => '/news', 'article' => 'Test'];
     $data2 = ['title' => 'test-1', 'tags' => ['tag1', 'tag2'], 'url' => '/news/test', 'article' => 'Test'];
     $client = $this->createAuthenticatedClient();
     $client->request('POST', '/api/nodes?template=default&webspace=sulu_io&language=en', $data1);
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     $uuid = $response->id;
     $client->request('POST', '/api/nodes?template=default&parent=' . $uuid . '&webspace=sulu_io&language=en', $data2);
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
     $response = json_decode($client->getResponse()->getContent());
     $this->assertEquals('test-1', $response->title);
     $this->assertEquals('Test', $response->article);
     $this->assertEquals('/news/test', $response->url);
     $this->assertEquals(['tag1', 'tag2'], $response->tags);
     $this->assertEquals($this->getTestUserId(), $response->creator);
     $this->assertEquals($this->getTestUserId(), $response->changer);
     $root = $this->session->getRootNode();
     $route = $root->getNode('cmf/sulu_io/routes/en/news/test');
     /** @var NodeInterface $content */
     $content = $route->getPropertyValue('sulu:content');
     $this->assertEquals('test-1', $content->getProperty('i18n:en-title')->getString());
     $this->assertEquals('Test', $content->getProperty('i18n:en-article')->getString());
     $this->assertCount(2, $content->getPropertyValue('i18n:en-tags'));
     $this->assertEquals($this->getTestUserId(), $content->getPropertyValue('i18n:en-creator'));
     $this->assertEquals($this->getTestUserId(), $content->getPropertyValue('i18n:en-changer'));
     // check parent
     $this->assertEquals($uuid, $content->getParent()->getIdentifier());
 }
Esempio n. 18
0
 /**
  * Updates the route for the given document after a move or copy.
  *
  * @param object $document
  * @param bool $generateRoutes If set to true a route in the routing tree will also be created
  */
 private function updateRoute($document, $generateRoutes)
 {
     $locales = $this->documentInspector->getLocales($document);
     $webspaceKey = $this->documentInspector->getWebspace($document);
     $uuid = $this->documentInspector->getUuid($document);
     $path = $this->documentInspector->getPath($document);
     $parentUuid = $this->documentInspector->getUuid($this->documentInspector->getParent($document));
     $defaultNode = $this->defaultSession->getNode($path);
     $liveNode = $this->liveSession->getNode($path);
     $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
     foreach ($locales as $locale) {
         $localizedDocument = $this->documentManager->find($uuid, $locale);
         if ($localizedDocument->getRedirectType() !== RedirectType::NONE) {
             continue;
         }
         $resourceSegmentPropertyName = $this->encoder->localizedSystemName($this->getResourceSegmentProperty($localizedDocument)->getName(), $locale);
         $this->updateResourceSegmentProperty($defaultNode, $resourceSegmentPropertyName, $parentUuid, $webspaceKey, $locale);
         if ($liveNode->hasProperty($resourceSegmentPropertyName)) {
             $this->updateResourceSegmentProperty($liveNode, $resourceSegmentPropertyName, $parentUuid, $webspaceKey, $locale);
             // if the method is called with the generateRoutes flag it will create a new route
             // this happens on a move, but not on copy, because copy results in a draft page without url
             if ($generateRoutes) {
                 $localizedDocument->setResourceSegment($liveNode->getPropertyValue($resourceSegmentPropertyName));
                 $resourceLocatorStrategy->save($localizedDocument, null);
                 $localizedDocument->setResourceSegment($defaultNode->getPropertyValue($resourceSegmentPropertyName));
             }
         }
     }
 }
Esempio n. 19
0
 /**
  * Normalize the given path or ID to a path.
  *
  * @param string $identifier
  *
  * @return string
  */
 private function normalizeToPath($identifier)
 {
     if (UUIDHelper::isUUID($identifier)) {
         $identifier = $this->session->getNodeByIdentifier($identifier)->getPath();
     }
     return $identifier;
 }
Esempio n. 20
0
 public function testRemove()
 {
     $this->property->expects($this->any())->method('getName')->will($this->returnValue('i18n:de-hotels'));
     $pageNode = $this->session->getNode('/cmf/sulu_io/contents/hotels');
     $this->contentType->remove($pageNode, $this->property, 'sulu_io', 'de', null);
     $this->session->save();
     $this->assertFalse($pageNode->hasProperty('i18n:de-hotels'));
 }
Esempio n. 21
0
 protected function createNode($id, $username, $primaryType = 'rep:root')
 {
     $repository = $this->getMockBuilder('Jackalope\\Repository')->disableOriginalConstructor()->getMock();
     $this->session->expects($this->any())->method('getRepository')->with()->will($this->returnValue($repository));
     $type = $this->getMockBuilder('Jackalope\\NodeType\\NodeType')->disableOriginalConstructor()->getMock();
     $type->expects($this->any())->method('getName')->with()->will($this->returnValue($primaryType));
     $ntm = $this->getMockBuilder('Jackalope\\NodeType\\NodeTypeManager')->disableOriginalConstructor()->getMock();
     $ntm->expects($this->any())->method('getNodeType')->with()->will($this->returnValue($type));
     $workspace = $this->getMockBuilder('Jackalope\\Workspace')->disableOriginalConstructor()->getMock();
     $workspace->expects($this->any())->method('getNodeTypeManager')->with()->will($this->returnValue($ntm));
     $this->session->expects($this->any())->method('getWorkspace')->with()->will($this->returnValue($workspace));
     $this->session->expects($this->any())->method('nodeExists')->with($id)->will($this->returnValue(true));
     $nodeData = array("jcr:primaryType" => $primaryType, "jcr:system" => array(), 'username' => $username);
     $node = new Node($this->factory, $nodeData, $id, $this->session, $this->objectManager);
     $this->session->expects($this->any())->method('getNode')->with($id)->will($this->returnValue($node));
     return $node;
 }
Esempio n. 22
0
 /**
  * {@inheritDoc}
  */
 public function getNodeForDocument($document)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $path = $this->unitOfWork->getDocumentId($document);
     return $this->session->getNode($path);
 }
 protected function removeTestNode()
 {
     $root = $this->session->getRootNode();
     if ($root->hasNode($this->testNodeName)) {
         $root->getNode($this->testNodeName)->remove();
         $this->session->save();
     }
 }
Esempio n. 24
0
 /**
  * Let the visitor visit the ancestors from root node according to mapper
  * down to the parent of the node identified by url
  *
  * @param string $url the url (without eventual prefix from routing config)
  * @param ItemVisitorInterface $visitor the visitor to look at the nodes
  */
 public function visitAncestors($url, ItemVisitorInterface $visitor)
 {
     $node = $this->session->getNode($this->mapper->getStorageId($url));
     $i = $this->rootnode->getDepth();
     while (($ancestor = $node->getAncestor($i++)) != $node) {
         $ancestor->accept($visitor);
     }
 }
Esempio n. 25
0
 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);
 }
Esempio n. 26
0
 /**
  * Refresh the given document by querying the PHPCR to get the current state.
  *
  * @param object $document
  * @return object Document instance
  */
 public function refresh($document)
 {
     $this->errorIfClosed();
     $this->session->refresh(true);
     $node = $this->session->getNode($this->unitOfWork->getDocumentId($document));
     $hints = array('refresh' => true);
     return $this->unitOfWork->createDocument(get_class($document), $node, $hints);
 }
Esempio n. 27
0
 /**
  * Iterates over all nodes of the given type, and upgrades them.
  *
  * @param StructureMetadata $structureMetadata The structure metadata, whose pages have to be upgraded
  * @param array $properties The properties which are or contain URL fields
  * @param bool $addScheme Adds the scheme to URLs if true, removes the scheme otherwise
  */
 private function iterateStructureNodes(StructureMetadata $structureMetadata, array $properties, $addScheme)
 {
     foreach ($this->localizationManager->getLocalizations() as $localization) {
         $rows = $this->session->getWorkspace()->getQueryManager()->createQuery(sprintf('SELECT * FROM [nt:unstructured] WHERE [%s] = "%s" OR [%s] = "%s"', $this->propertyEncoder->localizedSystemName('template', $localization->getLocalization()), $structureMetadata->getName(), 'template', $structureMetadata->getName()), 'JCR-SQL2')->execute();
         foreach ($rows->getNodes() as $node) {
             $this->upgradeNode($node, $localization->getLocalization(), $properties, $addScheme);
         }
     }
 }
Esempio n. 28
0
 /**
  * Imports workspace.
  *
  * @param SessionInterface $session
  * @param string $path
  * @param string $fileName
  */
 private function import(SessionInterface $session, $path, $fileName)
 {
     if ($session->nodeExists($path)) {
         $session->getNode($path)->remove();
         $session->save();
     }
     $session->importXML(PathHelper::getParentPath($path), $fileName, ImportUUIDBehaviorInterface::IMPORT_UUID_COLLISION_THROW);
     $session->save();
 }
 public function testDelete()
 {
     $structure = $this->prepareHistoryTestData();
     $this->repository->delete('/test', 'sulu_io', 'en');
     $this->session->save();
     $result = $this->repository->getHistory($structure->getUuid(), 'sulu_io', 'en');
     $this->assertEquals(1, count($result['_embedded']['resourcelocators']));
     $this->assertEquals('/test-1', $result['_embedded']['resourcelocators'][0]['resourceLocator']);
 }
Esempio n. 30
0
 /**
  * Remove a PHPCR node under the root node
  *
  * @param string $name The name of the node to remove
  *
  * @return void
  */
 protected function removeTestNode($name)
 {
     $root = $this->session->getNode('/');
     if ($root->hasNode($name)) {
         $root->getNode($name)->remove();
         $this->session->save();
         $this->dm->clear();
     }
 }