/**
  * @test
  */
 public function evaluateSkipsNodesNotAvailableInModifiedContext()
 {
     $suppliedContextProperties = array('infiniteImprobabilityDrive' => true);
     $nodeContextProperties = array('infiniteImprobabilityDrive' => false, 'autoRemoveUnsuitableContent' => true);
     $nodeIdentifier = 'c575c430-c971-11e3-a6e7-14109fd7a2dd';
     $mockNode = $this->createMock(NodeInterface::class);
     $mockNode->expects($this->any())->method('getIdentifier')->will($this->returnValue($nodeIdentifier));
     $mockFlowQuery = $this->buildFlowQueryWithNodeInContext($mockNode, $nodeContextProperties);
     $modifiedNodeContext = $this->getMockBuilder(Context::class)->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 getUnpublishedNodesDoesNotReturnInvalidNodes()
 {
     $mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $expectedContextProperties = array('workspaceName' => $this->mockWorkspace->getName(), 'inaccessibleContentShown' => true, 'invisibleContentShown' => true, 'removedContentShown' => true, 'dimensions' => array());
     $this->mockContextFactory->expects($this->any())->method('create')->with($expectedContextProperties)->will($this->returnValue($mockContext));
     $mockNodeData1 = $this->getMockBuilder(NodeData::class)->disableOriginalConstructor()->getMock();
     $mockNodeData2 = $this->getMockBuilder(NodeData::class)->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(NodeInterface::class)->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));
 }
 /**
  * @param string $nodePath
  * @param array $nodeTypeProperties
  * @return NodeInterface
  */
 protected function setUpNodeWithNodeType($nodePath, $nodeTypeProperties = array())
 {
     $mockLiveWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock();
     $mockNode = $this->createMock(NodeInterface::class);
     $mockNodeType = $this->getMockBuilder(NodeType::class)->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(Context::class)->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;
 }