Exemplo n.º 1
0
 /**
  * @test
  */
 public function createNodeFromTemplateUsesIdentifierFromTemplate()
 {
     $identifier = \TYPO3\Flow\Utility\Algorithms::generateUUID();
     $template = new \TYPO3\TYPO3CR\Domain\Model\NodeTemplate();
     $template->setName('new-node');
     $template->setIdentifier($identifier);
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNodeFromTemplate($template);
     $this->assertSame($identifier, $newNode->getIdentifier());
 }
 /**
  * @test
  */
 public function nodePathAvailableForNodeWillReturnFalseIfNodeWithGivenPathExistsAlready()
 {
     $this->workspaceRepository->add(new \TYPO3\TYPO3CR\Domain\Model\Workspace('live'));
     $rootNode = $this->context->getRootNode();
     $fooNode = $rootNode->createNode('foo');
     $fooNode->createNode('bar');
     $bazNode = $rootNode->createNode('baz');
     $this->persistenceManager->persistAll();
     $actualResult = $this->nodeService->nodePathAvailableForNode('/foo/bar', $bazNode);
     $this->assertFalse($actualResult);
 }
 /**
  * @test
  */
 public function findNodesByRelatedEntitiesFindsExistingNodeWithMatchingEntityProperty()
 {
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNode('test', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithEntities'));
     $testImage = new Image();
     $this->persistenceManager->add($testImage);
     $newNode->setProperty('image', $testImage);
     $this->persistenceManager->persistAll();
     $relationMap = array('TYPO3\\Flow\\Tests\\Functional\\Persistence\\Fixtures\\Image' => array($this->persistenceManager->getIdentifierByObject($testImage)));
     $result = $this->nodeDataRepository->findNodesByRelatedEntities($relationMap);
     $this->assertCount(1, $result);
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository');
     $liveWorkspace = new Workspace('live');
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\NodeTypeManager');
     $this->contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface');
     $this->context = $this->contextFactory->create(['workspaceName' => 'live', 'dimensions' => ['language' => ['en_US']], 'targetDimensions' => ['language' => 'en_US']]);
     $rootNode = $this->context->getRootNode();
     $this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $this->siteNode->setProperty('title', 'welcome');
     $this->nodeDataRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository');
     $this->nodeIndexCommandController = $this->objectManager->get('Flowpack\\ElasticSearch\\ContentRepositoryAdaptor\\Command\\NodeIndexCommandController');
     $this->createNodesForNodeSearchTest();
 }
 public function setUp()
 {
     parent::setUp();
     $this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
     $liveWorkspace = new Workspace('live');
     $this->workspaceRepository->add($liveWorkspace);
     $this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
     $this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
     $this->context = $this->contextFactory->create(['workspaceName' => 'live', 'dimensions' => ['language' => ['en_US']], 'targetDimensions' => ['language' => 'en_US']]);
     $rootNode = $this->context->getRootNode();
     $this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $this->siteNode->setProperty('title', 'welcome');
     $this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
     $this->nodeIndexCommandController = $this->objectManager->get(NodeIndexCommandController::class);
     $this->createNodesForNodeSearchTest();
 }
 /**
  * @test
  */
 public function getChildNodesWithNodeTypeFilterWorks()
 {
     $documentNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Document');
     $headlineNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Headline');
     $imageNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Image');
     $node = $this->context->getRootNode()->createNode('node-with-child-node', $documentNodeType);
     $node->createNode('headline', $headlineNodeType);
     $node->createNode('text', $imageNodeType);
     $this->assertCount(1, $node->getChildNodes('TYPO3.TYPO3CR.Testing:Headline'));
 }
 /**
  * @throws \TYPO3\TYPO3CR\Exception\NodeTypeNotFoundException
  */
 protected function createNodesForNodeSearchTest()
 {
     $rootNode = $this->context->getRootNode();
     $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType'));
     $newNode1->setProperty('test1', 'simpleTestValue');
     $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType'));
     $newNode2->setProperty('test2', 'simpleTestValue');
     $newNode2 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeType'));
     $newNode2->setProperty('test1', 'otherValue');
     $this->persistenceManager->persistAll();
 }
 /**
  * Creates some sample nodes to run tests against
  */
 protected function createNodesForNodeSearchTest()
 {
     $rootNode = $this->context->getRootNode();
     $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode1->setProperty('title', 'chicken');
     $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode2->setProperty('title', 'chicken');
     $newNode2 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode2->setProperty('title', 'egg');
     $this->persistenceManager->persistAll();
     $this->nodeIndexCommandController->buildCommand();
 }
 /**
  * @test
  */
 public function nodesCanHaveCustomImplementationClass()
 {
     $rootNode = $this->context->getRootNode();
     $testingNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:NodeTypeWithReferences');
     $happyNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:HappyTestingNode');
     $headlineNodeType = $this->nodeTypeManager->getNodeType('TYPO3.TYPO3CR.Testing:Headline');
     $fooNode = $rootNode->createNode('foo', $testingNodeType);
     $happyNode = $fooNode->createNode('bar', $happyNodeType);
     $bazNode = $happyNode->createNode('baz', $headlineNodeType);
     $this->assertNotInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $fooNode);
     $this->assertInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $happyNode);
     $this->assertNotInstanceOf('\\TYPO3\\TYPO3CR\\Tests\\Functional\\Domain\\Fixtures\\HappyNode', $bazNode);
     $this->assertEquals('bar claps hands!', $happyNode->clapsHands());
 }
 /**
  * Repair votes action
  *
  * Compare number of votes between nodes and vote log and repair, if not dryRun
  *
  * @param boolean $dryRun Don't do anything, but report actions
  * @return string
  */
 public function repairCommand($dryRun = TRUE)
 {
     if ($dryRun) {
         echo "Dry run, not making any changes\n";
     }
     $q = new FlowQuery(array($this->context->getRootNode()));
     $answerNodes = $q->find('[instanceof Sfi.Encult:Answer]')->get();
     foreach ($answerNodes as $answerNode) {
         /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
         $queryBuilder = $this->entityManager->createQueryBuilder();
         $nodes = $queryBuilder->select('v')->from('Sfi\\Encult\\Domain\\Model\\Vote', 'v')->andWhere('v.answerIdentifier = :answerIdentifier')->setParameters(array('answerIdentifier' => $answerNode->getIdentifier()))->getQuery()->getArrayResult();
         $dbCount = count($nodes);
         $crCount = $answerNode->getProperty('voteCount');
         $path = $answerNode->getPath();
         if ($dbCount !== $crCount) {
             echo "Found mistake for {$path} (db: {$dbCount} vs. cr: {$crCount})\n";
             if (!$dryRun) {
                 echo "Fixed\n";
                 $answerNode->setProperty('voteCount', $dbCount);
             }
         }
     }
     return "Done!\n";
 }
 /**
  * Creates some sample nodes to run tests against
  */
 protected function createNodesForNodeSearchTest()
 {
     $rootNode = $this->context->getRootNode();
     $newNode1 = $rootNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode1->setProperty('title', 'chicken');
     $newNode2 = $rootNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode2->setProperty('title', 'chicken');
     $newNode3 = $rootNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
     $newNode3->setProperty('title', 'egg');
     $dimensionContext = $this->contextFactory->create(array('workspaceName' => 'live', 'dimensions' => array('language' => array('de'))));
     $translatedNode3 = $dimensionContext->adoptNode($newNode3, TRUE);
     $translatedNode3->setProperty('title', 'Ei');
     $this->persistenceManager->persistAll();
     $this->nodeIndexCommandController->buildCommand();
 }
Exemplo n.º 12
0
 /**
  * @test
  */
 public function nodeDataRepositoryRenumbersNodesIfNoFreeSortingIndexesAreAvailable()
 {
     $rootNode = $this->context->getRootNode();
     $liveParentNode = $rootNode->createNode('parentNode');
     $nodes = array();
     $nodes[0] = $liveParentNode->createNode('node000');
     $nodes[150] = $liveParentNode->createNode('node150');
     $this->persistenceManager->persistAll();
     for ($i = 1; $i < 150; $i++) {
         $nodes[$i] = $liveParentNode->createNode('node' . sprintf('%1$03d', $i));
         $nodes[$i]->moveAfter($nodes[$i - 1]);
     }
     $this->persistenceManager->persistAll();
     ksort($nodes);
     $actualChildNodes = $liveParentNode->getChildNodes();
     $this->assertSameOrder($nodes, $actualChildNodes);
 }
 /**
  * @test
  */
 public function nodeWithRelatedEntitiesWillTakeCareOfAddingToPersistence()
 {
     $identifier = Algorithms::generateUUID();
     $template = new NodeTemplate();
     $template->setName('new-node');
     $template->setIdentifier($identifier);
     $newEntity = new Fixtures\RelatedEntity();
     $newEntity->setFavoritePlace('Reykjavik');
     $anotherNewEntity = new Fixtures\RelatedEntity();
     $anotherNewEntity->setFavoritePlace('Japan');
     $template->setProperty('entity', array($newEntity, $anotherNewEntity));
     $rootNode = $this->context->getRootNode();
     $newNode = $rootNode->createNodeFromTemplate($template);
     $this->persistenceManager->persistAll();
     $this->persistenceManager->clearState();
     $this->inject($this->contextFactory, 'contextInstances', array());
     $newLiveContext = $this->contextFactory->create(array('workspaceName' => 'live'));
     $newNodeAgain = $newLiveContext->getNode('/new-node');
     $entityArray = $newNodeAgain->getProperty('entity');
     $this->assertCount(2, $entityArray);
     $this->assertEquals('Japan', $entityArray[1]->getFavoritePlace());
 }
 protected function getNewsByOriginalId($id)
 {
     $q = new FlowQuery(array($this->context->getRootNode()));
     return $q->find('[instanceof Sfi.Kateheo:News]')->filter('[originalIdentifier = "' . $id . '"]')->get(0);
 }