/**
  * Prepare test objects
  */
 protected function setUp()
 {
     $this->nodeFactory = $this->getMockBuilder(NodeFactory::class)->setMethods(array('filterNodeByContext'))->getMock();
     $this->nodeFactory->expects(self::any())->method('filterNodeByContext')->willReturnArgument(0);
     $this->reflectionServiceMock = $this->createMock(ReflectionService::class);
     $this->reflectionServiceMock->expects(self::any())->method('getAllImplementationClassNamesForInterface')->with(NodeInterface::class)->willReturn(array(Node::class));
     $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
     $this->objectManagerMock->expects(self::any())->method('get')->with(ReflectionService::class)->willReturn($this->reflectionServiceMock);
     $this->objectManagerMock->expects(self::any())->method('getClassNameByObjectName')->with(NodeInterface::class)->willReturn(Node::class);
     $this->inject($this->nodeFactory, 'objectManager', $this->objectManagerMock);
 }
 /**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->identityRoutePart = $this->getAccessibleMock(IdentityRoutePart::class, ['createPathSegmentForObject']);
     $this->mockPersistenceManager = $this->createMock(PersistenceManagerInterface::class);
     $this->identityRoutePart->_set('persistenceManager', $this->mockPersistenceManager);
     $this->mockReflectionService = $this->createMock(ReflectionService::class);
     $this->mockClassSchema = $this->getMockBuilder(ClassSchema::class)->disableOriginalConstructor()->getMock();
     $this->mockReflectionService->expects($this->any())->method('getClassSchema')->will($this->returnValue($this->mockClassSchema));
     $this->identityRoutePart->_set('reflectionService', $this->mockReflectionService);
     $this->mockObjectPathMappingRepository = $this->createMock(ObjectPathMappingRepository::class);
     $this->identityRoutePart->_set('objectPathMappingRepository', $this->mockObjectPathMappingRepository);
 }
 /**
  * @test
  */
 public function getAvailableCommandsReturnsAllAvailableCommands()
 {
     $commandManager = new CommandManager();
     $mockCommandControllerClassNames = array(Fixtures\Command\MockACommandController::class, Fixtures\Command\MockBCommandController::class);
     $this->mockReflectionService->expects($this->once())->method('getAllSubClassNamesForClass')->with(Cli\CommandController::class)->will($this->returnValue($mockCommandControllerClassNames));
     $mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $mockObjectManager->expects($this->any())->method('get')->with(ReflectionService::class)->willReturn($this->mockReflectionService);
     $commandManager->injectObjectManager($mockObjectManager);
     $commands = $commandManager->getAvailableCommands();
     $this->assertEquals(3, count($commands));
     $this->assertEquals('neos.flow.tests.unit.cli.fixtures:mocka:foo', $commands[0]->getCommandIdentifier());
     $this->assertEquals('neos.flow.tests.unit.cli.fixtures:mocka:bar', $commands[1]->getCommandIdentifier());
     $this->assertEquals('neos.flow.tests.unit.cli.fixtures:mockb:baz', $commands[2]->getCommandIdentifier());
 }
 /**
  * @test
  */
 public function getTypeOfChildPropertyShouldRemoveLeadingBackslashesForAnnotationParameters()
 {
     $this->mockReflectionService->expects($this->any())->method('getMethodParameters')->with('TheTargetType', '__construct')->will($this->returnValue([]));
     $this->mockReflectionService->expects($this->any())->method('hasMethod')->with('TheTargetType', 'setThePropertyName')->will($this->returnValue(false));
     $this->mockReflectionService->expects($this->any())->method('getClassPropertyNames')->with('TheTargetType')->will($this->returnValue(['thePropertyName']));
     $this->mockReflectionService->expects($this->any())->method('getPropertyTagValues')->with('TheTargetType', 'thePropertyName')->will($this->returnValue(['\\TheTypeOfSubObject']));
     $configuration = new PropertyMappingConfiguration();
     $configuration->setTypeConverterOptions(ObjectConverter::class, []);
     $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration));
 }
 /**
  * @test
  */
 public function resolveValidatorObjectNameCallsGetValidatorType()
 {
     $mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $mockObjectManager->expects($this->any())->method('get')->with(ReflectionService::class)->will($this->returnValue($this->mockReflectionService));
     $this->mockReflectionService->expects($this->any())->method('getAllImplementationClassNamesForInterface')->with(ValidatorInterface::class)->will($this->returnValue([]));
     $validatorResolver = $this->getAccessibleMock(ValidatorResolver::class, ['getValidatorType']);
     $validatorResolver->_set('objectManager', $mockObjectManager);
     $validatorResolver->expects($this->once())->method('getValidatorType')->with('someDataType');
     $validatorResolver->_call('resolveValidatorObjectName', 'someDataType');
 }
 /**
  * @test
  * @expectedException \Neos\Flow\Property\Exception\InvalidTargetException
  */
 public function convertFromShouldThrowExceptionIfRequiredConstructorParameterWasNotFound()
 {
     $source = ['propertyX' => 'bar'];
     $object = new ClassWithSettersAndConstructor('param1');
     $convertedChildProperties = ['property2' => 'bar'];
     $this->mockReflectionService->expects($this->once())->method('hasMethod')->with(ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(true));
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with(ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(array('property1' => array('optional' => false, 'type' => null))));
     $this->mockObjectManager->expects($this->once())->method('getClassNameByObjectName')->with(ClassWithSettersAndConstructor::class)->will($this->returnValue(ClassWithSettersAndConstructor::class));
     $configuration = $this->buildConfiguration(array(PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => true));
     $result = $this->converter->convertFrom($source, ClassWithSettersAndConstructor::class, $convertedChildProperties, $configuration);
     $this->assertSame($object, $result);
 }
 /**
  * @test
  */
 public function prepareArgumentsRegistersAnnotationBasedArgumentsWithoutDescriptionIfDebugModeIsDisabled()
 {
     $dataCacheMock = $this->getMockBuilder(\Neos\Cache\Frontend\VariableFrontend::class)->disableOriginalConstructor()->getMock();
     $dataCacheMock->expects($this->any())->method('has')->will($this->returnValue(true));
     $dataCacheMock->expects($this->any())->method('get')->will($this->returnValue(array()));
     $viewHelper = new \Neos\FluidAdaptor\Core\Fixtures\TestViewHelper2();
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with(\Neos\FluidAdaptor\Core\Fixtures\TestViewHelper2::class, 'render')->will($this->returnValue($this->fixtureMethodParameters));
     $this->mockReflectionService->expects($this->once())->method('getMethodTagsValues');
     $viewHelper->injectObjectManager($this->mockObjectManager);
     $expected = array('param1' => new \Neos\FluidAdaptor\Core\ViewHelper\ArgumentDefinition('param1', 'integer', '', true, null, true), 'param2' => new \Neos\FluidAdaptor\Core\ViewHelper\ArgumentDefinition('param2', 'array', '', true, null, true), 'param3' => new \Neos\FluidAdaptor\Core\ViewHelper\ArgumentDefinition('param3', 'string', '', false, 'default', true));
     $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
 }