Пример #1
0
 /**
  * @test
  */
 public function processConvertsValueIfDataTypeIsSpecified()
 {
     $this->processingRule->setDataType('SomeDataType');
     $mockPropertyMappingConfiguration = $this->getMockBuilder(\Neos\Flow\Property\PropertyMappingConfiguration::class)->getMock();
     $this->processingRule->_set('propertyMappingConfiguration', $mockPropertyMappingConfiguration);
     $this->mockPropertyMapper->expects($this->once())->method('convert')->with('Some Value', 'SomeDataType', $mockPropertyMappingConfiguration)->will($this->returnValue('Converted Value'));
     $this->mockPropertyMapper->expects($this->any())->method('getMessages')->will($this->returnValue(new \Neos\Error\Messages\Result()));
     $this->assertEquals('Converted Value', $this->processingRule->process('Some Value'));
 }
 /**
  * @test
  */
 public function handleMergesInternalArgumentsWithRoutingMatchResults()
 {
     $this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue(['__internalArgument1' => 'request', '__internalArgument2' => 'request', '__internalArgument3' => 'request']));
     $this->mockHttpRequest->expects(self::any())->method('getContent')->willReturn('requestBody');
     $this->mockPropertyMapper->expects($this->any())->method('convert')->will($this->returnValue(['__internalArgument2' => 'requestBody', '__internalArgument3' => 'requestBody']));
     $this->mockComponentContext->expects($this->atLeastOnce())->method('getParameter')->with(RoutingComponent::class, 'matchResults')->will($this->returnValue(['__internalArgument3' => 'routing']));
     $this->mockActionRequest->expects($this->once())->method('setArguments')->with(['__internalArgument1' => 'request', '__internalArgument2' => 'requestBody', '__internalArgument3' => 'routing']);
     $this->dispatchComponent->handle($this->mockComponentContext);
 }
 /**
  * @test
  */
 public function convertFromUsesPropertyMapperToConvertNodePropertyOfArrayType()
 {
     $contextPath = '/foo/bar@user-demo';
     $nodePath = '/foo/bar';
     $nodeTypeProperties = array('assets' => array('type' => 'array<Neos\\Media\\Domain\\Model\\Asset>'));
     $decodedPropertyValue = array('8aaf4dd2-bd85-11e3-ae3d-14109fd7a2dd', '8febe94a-bd85-11e3-8401-14109fd7a2dd');
     $source = array('__contextNodePath' => $contextPath, 'assets' => json_encode($decodedPropertyValue));
     $convertedPropertyValue = array(new \stdClass(), new \stdClass());
     $mockNode = $this->setUpNodeWithNodeType($nodePath, $nodeTypeProperties);
     $this->mockObjectManager->expects($this->any())->method('isRegistered')->with(Asset::class)->will($this->returnValue(true));
     $this->mockPropertyMapper->expects($this->once())->method('convert')->with($decodedPropertyValue, $nodeTypeProperties['assets']['type'])->will($this->returnValue($convertedPropertyValue));
     $mockNode->expects($this->once())->method('setProperty')->with('assets', $convertedPropertyValue);
     $this->nodeConverter->convertFrom($source, null, array(), $this->mockConverterConfiguration);
 }
 /**
  * @test
  */
 public function hiddenFieldContainsDataOfAPreviouslyUploadedResource()
 {
     $mockResourceUuid = '79ecda60-1a27-69ca-17bf-a5d9e80e6c39';
     $submittedData = array('foo' => array('bar' => array('name' => 'someFilename.jpg', 'type' => 'image/jpeg', 'tmp_name' => '/some/tmp/name', 'error' => 0, 'size' => 123)));
     /** @var Result|\PHPUnit_Framework_MockObject_MockObject $mockValidationResults */
     $mockValidationResults = $this->getMockBuilder(Result::class)->disableOriginalConstructor()->getMock();
     $mockValidationResults->expects($this->atLeastOnce())->method('hasErrors')->will($this->returnValue(true));
     $this->request->expects($this->at(0))->method('getInternalArgument')->with('__submittedArgumentValidationResults')->will($this->returnValue($mockValidationResults));
     $this->request->expects($this->at(1))->method('getInternalArgument')->with('__submittedArguments')->will($this->returnValue($submittedData));
     /** @var PersistentResource|\PHPUnit_Framework_MockObject_MockObject $mockResource */
     $mockResource = $this->getMockBuilder(PersistentResource::class)->disableOriginalConstructor()->getMock();
     $mockPersistenceManager = $this->createMock(PersistenceManagerInterface::class);
     $mockPersistenceManager->expects($this->once())->method('getIdentifierByObject')->with($mockResource)->will($this->returnValue($mockResourceUuid));
     $this->inject($this->viewHelper, 'persistenceManager', $mockPersistenceManager);
     $this->mockPropertyMapper->expects($this->atLeastOnce())->method('convert')->with($submittedData['foo']['bar'], PersistentResource::class)->will($this->returnValue($mockResource));
     $mockValueResource = $this->getMockBuilder(PersistentResource::class)->disableOriginalConstructor()->getMock();
     $this->viewHelper->setArguments(array('name' => 'foo[bar]', 'value' => $mockValueResource));
     $expectedResult = '<input type="hidden" name="foo[bar][originallySubmittedResource][__identity]" value="' . $mockResourceUuid . '" />';
     $this->viewHelper->initialize();
     $actualResult = $this->viewHelper->render();
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * @test
  */
 public function importWithLinebreakInDateTimeImportsCorrectly()
 {
     $xmlReader = new \XMLReader();
     $result = $xmlReader->open(__DIR__ . '/Fixtures/SingleNodeWithLinebreaks.xml', null, LIBXML_PARSEHUGE);
     $this->assertTrue($result);
     /** @var \Neos\ContentRepository\Domain\Service\ImportExport\NodeImportService $nodeImportService */
     $nodeImportService = $this->getMockBuilder(\Neos\ContentRepository\Domain\Service\ImportExport\NodeImportService::class)->setMethods(array('persistNodeData'))->getMock();
     $this->inject($nodeImportService, 'propertyMapper', $this->mockPropertyMapper);
     $this->inject($nodeImportService, 'securityContext', $this->mockSecurityContext);
     $expectedNodeDatas = array(array('creationDateTime' => array('source' => '2015-12-21T21:56:53+00:00')));
     $nodeImportService->expects($this->atLeastOnce())->method('persistNodeData')->will($this->returnCallback(function ($nodeData) use(&$actualNodeDatas) {
         unset($nodeData['Persistence_Object_Identifier']);
         $actualNodeDatas[] = $nodeData;
         return true;
     }));
     $this->mockPropertyMapper->expects($this->any())->method('convert')->will($this->returnCallback(function ($source, $targetType) {
         return array('targetType' => $targetType, 'source' => $source);
     }));
     $this->mockPropertyMapper->expects($this->any())->method('getMessages')->willReturn(new \Neos\Error\Messages\Result());
     $nodeImportService->import($xmlReader, '/');
     $this->assertCount(1, $actualNodeDatas);
     $this->assertArraySubset($expectedNodeDatas[0]['creationDateTime'], $actualNodeDatas[0]['creationDateTime'], true);
 }
 /**
  */
 public function setUp()
 {
     $this->ajaxWidgetComponent = new AjaxWidgetComponent();
     $this->mockObjectManager = $this->createMock(\Neos\Flow\ObjectManagement\ObjectManagerInterface::class);
     $this->inject($this->ajaxWidgetComponent, 'objectManager', $this->mockObjectManager);
     $this->mockComponentContext = $this->getMockBuilder(\Neos\Flow\Http\Component\ComponentContext::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest = $this->getMockBuilder(\Neos\Flow\Http\Request::class)->disableOriginalConstructor()->getMock();
     $this->mockHttpRequest->expects($this->any())->method('getArguments')->will($this->returnValue(array()));
     $this->mockComponentContext->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockHttpResponse = $this->getMockBuilder(\Neos\Flow\Http\Response::class)->disableOriginalConstructor()->getMock();
     $this->mockComponentContext->expects($this->any())->method('getHttpResponse')->will($this->returnValue($this->mockHttpResponse));
     $this->mockAjaxWidgetContextHolder = $this->getMockBuilder(\Neos\FluidAdaptor\Core\Widget\AjaxWidgetContextHolder::class)->getMock();
     $this->inject($this->ajaxWidgetComponent, 'ajaxWidgetContextHolder', $this->mockAjaxWidgetContextHolder);
     $this->mockHashService = $this->getMockBuilder(\Neos\Flow\Security\Cryptography\HashService::class)->getMock();
     $this->inject($this->ajaxWidgetComponent, 'hashService', $this->mockHashService);
     $this->mockDispatcher = $this->getMockBuilder(\Neos\Flow\Mvc\Dispatcher::class)->getMock();
     $this->inject($this->ajaxWidgetComponent, 'dispatcher', $this->mockDispatcher);
     $this->mockSecurityContext = $this->getMockBuilder(\Neos\Flow\Security\Context::class)->getMock();
     $this->inject($this->ajaxWidgetComponent, 'securityContext', $this->mockSecurityContext);
     $this->mockPropertyMapper = $this->getMockBuilder(\Neos\Flow\Property\PropertyMapper::class)->disableOriginalConstructor()->getMock();
     $this->mockPropertyMapper->expects($this->any())->method('convert')->with('', 'array', $this->mockPropertyMappingConfiguration)->will($this->returnValue(array()));
     $this->inject($this->ajaxWidgetComponent, 'propertyMapper', $this->mockPropertyMapper);
 }