/** * @test */ public function evaluateSkipsNodesNotAvailableInModifiedContext() { $suppliedContextProperties = array('infiniteImprobabilityDrive' => true); $nodeContextProperties = array('infiniteImprobabilityDrive' => false, 'autoRemoveUnsuitableContent' => true); $nodeIdentifier = 'c575c430-c971-11e3-a6e7-14109fd7a2dd'; $mockNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface'); $mockNode->expects($this->any())->method('getIdentifier')->will($this->returnValue($nodeIdentifier)); $mockFlowQuery = $this->buildFlowQueryWithNodeInContext($mockNode, $nodeContextProperties); $modifiedNodeContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $this->mockContextFactory->expects($this->any())->method('create')->will($this->returnValue($modifiedNodeContext)); $modifiedNodeContext->expects($this->once())->method('getNodeByIdentifier')->with($nodeIdentifier)->will($this->returnValue(null)); $mockFlowQuery->expects($this->atLeastOnce())->method('setContext')->with(array()); $this->operation->evaluate($mockFlowQuery, array($suppliedContextProperties)); }
/** * @test */ public function convertFromSetsRemovedContentShownContextPropertyFromConfigurationForContextPathSource() { $contextPath = '/foo/bar@user-demo'; $mockLiveWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $mockNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface'); $mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($mockLiveWorkspace)); $mockContext->expects($this->any())->method('getNodeByIdentifier')->with($contextPath)->will($this->returnValue($mockNode)); $this->mockConverterConfiguration->expects($this->any())->method('getConfigurationValue')->with('TYPO3\\TYPO3CR\\TypeConverter\\NodeConverter', NodeConverter::REMOVED_CONTENT_SHOWN)->will($this->returnValue(TRUE)); $this->mockContextFactory->expects($this->any())->method('create')->with($this->callback(function ($properties) { Assert::assertTrue(isset($properties['removedContentShown']), 'removedContentShown context property should be set'); Assert::assertTrue($properties['removedContentShown'], 'removedContentShown context property should be TRUE'); return TRUE; }))->will($this->returnValue($mockContext)); $this->nodeConverter->convertFrom($contextPath, NULL, array(), $this->mockConverterConfiguration); }
/** * @param string $nodePath * @param array $nodeTypeProperties * @return NodeInterface */ protected function setUpNodeWithNodeType($nodePath, $nodeTypeProperties = array()) { $mockLiveWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock(); $mockNode = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface'); $mockNodeType = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeType')->disableOriginalConstructor()->getMock(); $mockNodeType->expects($this->any())->method('getProperties')->will($this->returnValue($nodeTypeProperties)); $mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue($mockNodeType)); $mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($mockLiveWorkspace)); $mockContext->expects($this->any())->method('getNode')->with($nodePath)->will($this->returnValue($mockNode)); $mockNode->expects($this->any())->method('getContext')->will($this->returnValue($mockContext)); // Simulate context properties by returning the same properties that were given to the ContextFactory $this->mockContextFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($contextProperties) use($mockContext) { $mockContext->expects($this->any())->method('getProperties')->will($this->returnValue($contextProperties)); return $mockContext; })); return $mockNode; }
/** * @test */ public function getUnpublishedNodesDoesNotReturnInvalidNodes() { $mockContext = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\Context')->disableOriginalConstructor()->getMock(); $expectedContextProperties = array('workspaceName' => $this->mockWorkspace->getName(), 'inaccessibleContentShown' => true, 'invisibleContentShown' => true, 'removedContentShown' => true, 'currentSite' => $this->mockSite, 'dimensions' => array()); $this->mockContextFactory->expects($this->any())->method('create')->with($expectedContextProperties)->will($this->returnValue($mockContext)); $mockNodeData1 = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData')->disableOriginalConstructor()->getMock(); $mockNodeData2 = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeData')->disableOriginalConstructor()->getMock(); $mockNodeData1->expects($this->any())->method('getDimensionValues')->will($this->returnValue(array())); $mockNodeData2->expects($this->any())->method('getDimensionValues')->will($this->returnValue(array())); $mockNode1 = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->getMock(); $mockNode1->expects($this->any())->method('getNodeData')->will($this->returnValue($mockNodeData1)); $mockNode1->expects($this->any())->method('getPath')->will($this->returnValue('/node1')); $this->mockNodeFactory->expects($this->at(0))->method('createFromNodeData')->with($mockNodeData1, $mockContext)->will($this->returnValue($mockNode1)); $this->mockNodeFactory->expects($this->at(1))->method('createFromNodeData')->with($mockNodeData2, $mockContext)->will($this->returnValue(null)); $this->mockNodeDataRepository->expects($this->atLeastOnce())->method('findByWorkspace')->with($this->mockWorkspace)->will($this->returnValue(array($mockNodeData1, $mockNodeData2))); $actualResult = $this->publishingService->getUnpublishedNodes($this->mockWorkspace); $this->assertSame($actualResult, array($mockNode1)); }
/** * @test */ public function resolveCreatesContextForTheWorkspaceMentionedInTheContextString() { $mockContext = $this->buildMockContext(array('workspaceName' => 'user-johndoe')); $mockContext->mockSite = $this->getMockBuilder(Site::class)->disableOriginalConstructor()->getMock(); $mockContext->mockSiteNode = $this->buildSiteNode($mockContext, '/sites/examplecom'); $mockSubNode = $this->buildSubNode($mockContext->mockSiteNode, 'home'); $mockSubNode->mockProperties['uriPathSegment'] = 'home'; // resolveValue() will use $contentContext to retrieve the resolved node: $mockContext->expects($this->any())->method('getNode')->will($this->returnCallback(function ($nodePath) use($mockSubNode) { return $nodePath === '/sites/examplecom/home' ? $mockSubNode : null; })); $that = $this; $this->mockContextFactory->expects($this->once())->method('create')->will($this->returnCallback(function ($contextProperties) use($that, $mockContext) { // The important assertion: $that->assertSame('user-johndoe', $contextProperties['workspaceName']); return $mockContext; })); $routeValues = array('node' => '/sites/examplecom/home@user-johndoe'); $this->assertTrue($this->routePartHandler->resolve($routeValues)); }
/** * @test */ public function resolveCreatesContextForCurrentDomainIfGivenValueIsAStringAndADomainIsFound() { $mockContext = $this->buildMockContext(array('workspaceName' => 'user-johndoe')); $mockContext->mockSite = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Model\\Site', array(), array(), '', false); $mockSiteNode = $this->buildSiteNode($mockContext, '/sites/examplecom'); $mockContext->mockSiteNode = $mockSiteNode; $mockContext->expects($this->any())->method('getNode')->will($this->returnCallback(function ($nodePath) use($mockSiteNode) { return $nodePath === '/sites/examplecom' ? $mockSiteNode : null; })); $mockDomain = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Model\\Domain')->disableOriginalConstructor()->getMock(); $this->mockDomainRepository->expects($this->atLeastOnce())->method('findOneByActiveRequest')->will($this->returnValue($mockDomain)); $that = $this; $this->mockContextFactory->expects($this->once())->method('create')->will($this->returnCallback(function ($contextProperties) use($that, $mockContext, $mockDomain) { // The important assertion: $that->assertSame($mockDomain, $contextProperties['currentDomain']); return $mockContext; })); $routeValues = array('node' => '/sites/examplecom'); $this->assertTrue($this->routePartHandler->resolve($routeValues)); }