/**
  * @test
  */
 public function getTypeOfChildPropertyShouldUseReflectionServiceToDetermineType()
 {
     $this->mockReflectionService->expects($this->any())->method('hasMethod')->with('TheTargetType', 'setThePropertyName')->will($this->returnValue(FALSE));
     $this->mockReflectionService->expects($this->any())->method('getMethodParameters')->with('TheTargetType', '__construct')->will($this->returnValue(array('thePropertyName' => array('type' => 'TheTypeOfSubObject', 'elementType' => NULL))));
     $configuration = new \TYPO3\Flow\Property\PropertyMappingConfiguration();
     $configuration->setTypeConverterOptions(\TYPO3\Flow\Property\TypeConverter\ObjectConverter::class, array());
     $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration));
 }
 public function setUp()
 {
     $this->commandController = $this->getAccessibleMock('TYPO3\\Flow\\Cli\\CommandController', array('resolveCommandMethodName', 'callCommandMethod'));
     $this->mockReflectionService = $this->getMockBuilder('TYPO3\\Flow\\Reflection\\ReflectionService')->disableOriginalConstructor()->getMock();
     $this->mockReflectionService->expects($this->any())->method('getMethodParameters')->will($this->returnValue(array()));
     $this->inject($this->commandController, 'reflectionService', $this->mockReflectionService);
     $this->mockConsoleOutput = $this->getMockBuilder('TYPO3\\Flow\\Cli\\ConsoleOutput')->disableOriginalConstructor()->getMock();
     $this->inject($this->commandController, 'output', $this->mockConsoleOutput);
 }
 /**
  * @test
  */
 public function getTypeOfChildPropertyShouldRemoveLeadingBackslashesForAnnotationParameters()
 {
     $this->mockReflectionService->expects($this->any())->method('getMethodParameters')->with('TheTargetType', '__construct')->will($this->returnValue(array()));
     $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(array('thePropertyName')));
     $this->mockReflectionService->expects($this->any())->method('getPropertyTagValues')->with('TheTargetType', 'thePropertyName')->will($this->returnValue(array('\\TheTypeOfSubObject')));
     $configuration = new \TYPO3\Flow\Property\PropertyMappingConfiguration();
     $configuration->setTypeConverterOptions(\TYPO3\Flow\Property\TypeConverter\ObjectConverter::class, array());
     $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration));
 }
 /**
  * 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);
 }
 /**
  * Prepare test objects
  */
 protected function setUp()
 {
     $this->nodeFactory = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Factory\\NodeFactory', array('filterNodeByContext'));
     $this->nodeFactory->expects(self::any())->method('filterNodeByContext')->willReturnArgument(0);
     $this->reflectionServiceMock = $this->getMock('TYPO3\\Flow\\Reflection\\ReflectionService');
     $this->reflectionServiceMock->expects(self::any())->method('getAllImplementationClassNamesForInterface')->with('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->willReturn(array('TYPO3\\TYPO3CR\\Domain\\Model\\Node'));
     $this->objectManagerMock = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface');
     $this->objectManagerMock->expects(self::any())->method('get')->with('TYPO3\\Flow\\Reflection\\ReflectionService')->willReturn($this->reflectionServiceMock);
     $this->objectManagerMock->expects(self::any())->method('getClassNameByObjectName')->with('TYPO3\\TYPO3CR\\Domain\\Model\\NodeInterface')->willReturn('TYPO3\\TYPO3CR\\Domain\\Model\\Node');
     $this->inject($this->nodeFactory, 'objectManager', $this->objectManagerMock);
 }
 /**
  * @test
  */
 public function getAvailableCommandsReturnsAllAvailableCommands()
 {
     $commandManager = new CommandManager();
     $commandManager->injectReflectionService($this->mockReflectionService);
     $mockCommandControllerClassNames = array(\TYPO3\Flow\Tests\Unit\Cli\Fixtures\Command\MockACommandController::class, \TYPO3\Flow\Tests\Unit\Cli\Fixtures\Command\MockBCommandController::class);
     $this->mockReflectionService->expects($this->once())->method('getAllSubClassNamesForClass')->with(\TYPO3\Flow\Cli\CommandController::class)->will($this->returnValue($mockCommandControllerClassNames));
     $commands = $commandManager->getAvailableCommands();
     $this->assertEquals(3, count($commands));
     $this->assertEquals('typo3.flow.tests.unit.cli.fixtures:mocka:foo', $commands[0]->getCommandIdentifier());
     $this->assertEquals('typo3.flow.tests.unit.cli.fixtures:mocka:bar', $commands[1]->getCommandIdentifier());
     $this->assertEquals('typo3.flow.tests.unit.cli.fixtures:mockb:baz', $commands[2]->getCommandIdentifier());
 }
 /**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->identityRoutePart = $this->getAccessibleMock(\TYPO3\Flow\Mvc\Routing\IdentityRoutePart::class, array('createPathSegmentForObject'));
     $this->mockPersistenceManager = $this->getMock(\TYPO3\Flow\Persistence\PersistenceManagerInterface::class);
     $this->identityRoutePart->_set('persistenceManager', $this->mockPersistenceManager);
     $this->mockReflectionService = $this->getMock(\TYPO3\Flow\Reflection\ReflectionService::class);
     $this->mockClassSchema = $this->getMock(\TYPO3\Flow\Reflection\ClassSchema::class, array(), array(), '', false);
     $this->mockReflectionService->expects($this->any())->method('getClassSchema')->will($this->returnValue($this->mockClassSchema));
     $this->identityRoutePart->_set('reflectionService', $this->mockReflectionService);
     $this->mockObjectPathMappingRepository = $this->getMock(\TYPO3\Flow\Mvc\Routing\ObjectPathMappingRepository::class);
     $this->identityRoutePart->_set('objectPathMappingRepository', $this->mockObjectPathMappingRepository);
 }
 /**
  * @test
  * @dataProvider quotedValues
  */
 public function quotedArgumentValuesAreCorrectlyParsedWhenPassingTheCommandAsString($quotedArgument, $expectedResult)
 {
     $methodParameters = array('requiredArgument1' => array('optional' => FALSE, 'type' => 'string'), 'requiredArgument2' => array('optional' => FALSE, 'type' => 'string'));
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('Acme\\Test\\Command\\DefaultCommandController', 'listCommand')->will($this->returnValue($methodParameters));
     $expectedArguments = array('requiredArgument1' => 'firstArgumentValue', 'requiredArgument2' => $expectedResult);
     $request = $this->requestBuilder->build('acme.test:default:list firstArgumentValue ' . $quotedArgument);
     $this->assertEquals($expectedArguments, $request->getArguments());
 }
 /**
  * @test
  */
 public function resolveValidatorObjectNameCallsGetValidatorType()
 {
     $mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface');
     $mockObjectManager->expects($this->any())->method('get')->with('TYPO3\\Flow\\Reflection\\ReflectionService')->will($this->returnValue($this->mockReflectionService));
     $this->mockReflectionService->expects($this->any())->method('getAllImplementationClassNamesForInterface')->with('TYPO3\\Flow\\Validation\\Validator\\ValidatorInterface')->will($this->returnValue(array()));
     $validatorResolver = $this->getAccessibleMock('TYPO3\\Flow\\Validation\\ValidatorResolver', array('getValidatorType'));
     $validatorResolver->_set('objectManager', $mockObjectManager);
     $validatorResolver->expects($this->once())->method('getValidatorType')->with('someDataType');
     $validatorResolver->_call('resolveValidatorObjectName', 'someDataType');
 }
 /**
  * @test
  * @expectedException \TYPO3\Flow\Property\Exception\InvalidTargetException
  */
 public function convertFromShouldThrowExceptionIfRequiredConstructorParameterWasNotFound()
 {
     $source = array('propertyX' => 'bar');
     $object = new ClassWithSettersAndConstructor('param1');
     $convertedChildProperties = array('property2' => 'bar');
     $this->mockReflectionService->expects($this->once())->method('hasMethod')->with(\TYPO3\Flow\Fixtures\ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(true));
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with(\TYPO3\Flow\Fixtures\ClassWithSettersAndConstructor::class, '__construct')->will($this->returnValue(array('property1' => array('optional' => false, 'type' => null))));
     $this->mockObjectManager->expects($this->once())->method('getClassNameByObjectName')->with(\TYPO3\Flow\Fixtures\ClassWithSettersAndConstructor::class)->will($this->returnValue(\TYPO3\Flow\Fixtures\ClassWithSettersAndConstructor::class));
     $configuration = $this->buildConfiguration(array(PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => true));
     $result = $this->converter->convertFrom($source, \TYPO3\Flow\Fixtures\ClassWithSettersAndConstructor::class, $convertedChildProperties, $configuration);
     $this->assertSame($object, $result);
 }
 /**
  * @test
  */
 public function prepareArgumentsRegistersAnnotationBasedArgumentsWithoutDescriptionIfDebugModeIsDisabled()
 {
     \TYPO3\Fluid\Fluid::$debugMode = FALSE;
     $dataCacheMock = $this->getMock('TYPO3\\Flow\\Cache\\Frontend\\VariableFrontend', array(), array(), '', FALSE);
     $dataCacheMock->expects($this->any())->method('has')->will($this->returnValue(TRUE));
     $dataCacheMock->expects($this->any())->method('get')->will($this->returnValue(array()));
     $viewHelper = new \TYPO3\Fluid\Core\Fixtures\TestViewHelper2();
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with('TYPO3\\Fluid\\Core\\Fixtures\\TestViewHelper2', 'render')->will($this->returnValue($this->fixtureMethodParameters));
     $this->mockReflectionService->expects($this->never())->method('getMethodTagsValues');
     $viewHelper->injectObjectManager($this->mockObjectManager);
     $expected = array('param1' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param1', 'integer', '', TRUE, NULL, TRUE), 'param2' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param2', 'array', '', TRUE, NULL, TRUE), 'param3' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param3', 'string', '', FALSE, 'default', TRUE));
     $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
 }
 /**
  * @test
  */
 public function prepareArgumentsRegistersAnnotationBasedArgumentsWithoutDescriptionIfDebugModeIsDisabled()
 {
     \TYPO3\Fluid\Fluid::$debugMode = false;
     $dataCacheMock = $this->getMockBuilder(\TYPO3\Flow\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 \TYPO3\Fluid\Core\Fixtures\TestViewHelper2();
     $this->mockReflectionService->expects($this->once())->method('getMethodParameters')->with(\TYPO3\Fluid\Core\Fixtures\TestViewHelper2::class, 'render')->will($this->returnValue($this->fixtureMethodParameters));
     $this->mockReflectionService->expects($this->never())->method('getMethodTagsValues');
     $viewHelper->injectObjectManager($this->mockObjectManager);
     $expected = array('param1' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param1', 'integer', '', true, null, true), 'param2' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param2', 'array', '', true, null, true), 'param3' => new \TYPO3\Fluid\Core\ViewHelper\ArgumentDefinition('param3', 'string', '', false, 'default', true));
     $this->assertEquals($expected, $viewHelper->prepareArguments(), 'Annotation based arguments were not registered.');
 }