/**
  * @test
  */
 public function convertFromDecodesJsonEncodedArraysAsAssociative()
 {
     $contextPath = '/foo/bar@user-demo';
     $nodePath = '/foo/bar';
     $nodeTypeProperties = array('quux' => array('type' => 'array'));
     $decodedPropertyValue = array('foo' => 'bar');
     $source = array('__contextNodePath' => $contextPath, 'quux' => json_encode($decodedPropertyValue));
     $mockNode = $this->setUpNodeWithNodeType($nodePath, $nodeTypeProperties);
     $mockNode->expects($this->once())->method('setProperty')->with('quux', $decodedPropertyValue);
     $this->nodeConverter->convertFrom($source, null, array(), $this->mockConverterConfiguration);
 }
 /**
  * Additionally add the current site and domain to the Context properties.
  *
  * {@inheritdoc}
  */
 protected function prepareContextProperties($workspaceName, \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration = null, array $dimensions = null)
 {
     $contextProperties = parent::prepareContextProperties($workspaceName, $configuration, $dimensions);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $contextProperties;
 }
 /**
  * @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);
 }
 /**
  * Helper which calls the NodeConverter; with some error-handling built in
  *
  * @param $nodePath
  * @return NodeInterface
  */
 protected function convert($nodePath, PropertyMappingConfiguration $propertyMappingConfiguration = null)
 {
     $nodeConverter = new NodeConverter();
     $result = $nodeConverter->convertFrom($nodePath, null, array(), $propertyMappingConfiguration);
     if ($result instanceof Error) {
         $this->fail('Failed with error: ' . $result->getMessage());
     }
     return $result;
 }