49 $this->simpleValueArgument = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Controller\Argument', array(
'dummy'), array(
'someName',
'string'));
50 $this->objectArgument = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Controller\Argument', array(
'dummy'), array(
'someName',
'DateTime'));
51 $this->mockPropertyMapper = $this->getMock(
'TYPO3\\CMS\\Extbase\\Property\\PropertyMapper');
52 $this->simpleValueArgument->_set(
'propertyMapper', $this->mockPropertyMapper);
53 $this->objectArgument->_set(
'propertyMapper', $this->mockPropertyMapper);
54 $this->mockConfiguration = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration();
55 $propertyMappingConfiguranion = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration();
56 $this->simpleValueArgument->_set(
'propertyMappingConfiguration', $propertyMappingConfiguranion);
57 $this->objectArgument->_set(
'propertyMappingConfiguration', $propertyMappingConfiguranion);
66 new \TYPO3\CMS\Extbase\Mvc\Controller\Argument(
'',
'Text');
75 new \TYPO3\CMS\Extbase\Mvc\Controller\Argument(
new \ArrayObject(),
'Text');
83 $this->assertEquals(
'string', $this->simpleValueArgument->getDataType(),
'The specified data type has not been set correctly.');
84 $this->assertEquals(
'someName', $this->simpleValueArgument->getName(),
'The specified name has not been set correctly.');
92 $returnedArgument = $this->simpleValueArgument->setShortName(
'x');
93 $this->assertSame($this->simpleValueArgument, $returnedArgument,
'The returned argument is not the original argument.');
115 $this->simpleValueArgument->setShortName($invalidShortName);
123 $this->simpleValueArgument->setShortName(
'x');
124 $this->assertEquals(
'x', $this->simpleValueArgument->getShortName());
132 $returnedArgument = $this->simpleValueArgument->setRequired(TRUE);
133 $this->assertSame($this->simpleValueArgument, $returnedArgument,
'The returned argument is not the original argument.');
134 $this->assertTrue($this->simpleValueArgument->isRequired());
142 $returnedArgument = $this->simpleValueArgument->setDefaultValue(
'default');
143 $this->assertSame($this->simpleValueArgument, $returnedArgument,
'The returned argument is not the original argument.');
144 $this->assertSame(
'default', $this->simpleValueArgument->getDefaultValue());
152 $mockValidator = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface');
153 $returnedArgument = $this->simpleValueArgument->setValidator($mockValidator);
154 $this->assertSame($this->simpleValueArgument, $returnedArgument,
'The returned argument is not the original argument.');
155 $this->assertSame($mockValidator, $this->simpleValueArgument->getValidator());
164 $returnedArgument = $this->simpleValueArgument->setValue(NULL);
165 $this->assertSame($this->simpleValueArgument, $returnedArgument,
'The returned argument is not the original argument.');
173 $this->simpleValueArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument(
'dummy',
'string');
174 $this->simpleValueArgument = $this->
getAccessibleMock(
'TYPO3\CMS\Extbase\Mvc\Controller\Argument', array(
'dummy'), array(
'dummy',
'string'));
176 $this->simpleValueArgument->setValue(NULL);
177 $this->assertNull($this->simpleValueArgument->getValue());
186 array(
'ExtbaseTeam\\BlogExample\\Foo\\Bar'),
194 public function classSchemaIsBuiltForClassNameDataTypesWhenReflectionServiceIsInjected($dataType) {
196 $argument = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'dummy'), array(),
'', FALSE);
197 $argument->_set(
'dataType', $dataType);
198 $reflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
199 $reflectionService->expects($this->once())->method(
'getClassSchema')->with($dataType);
200 $argument->injectReflectionService($reflectionService);
218 public function classSchemaIsNotBuiltForPrimitiveDataTypesWhenReflectionServiceIsInjected($dataType) {
220 $argument = $this->
getAccessibleMock(
'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\Argument', array(
'dummy'), array(),
'', FALSE);
221 $argument->_set(
'dataType', $dataType);
222 $reflectionService = $this->getMock(
'TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService');
223 $reflectionService->expects($this->never())->method(
'getClassSchema');
224 $argument->injectReflectionService($reflectionService);
233 $this->mockPropertyMapper->expects($this->never())->method(
'convert');
234 $this->objectArgument->setValue(
new \DateTime());
241 $this->mockPropertyMapper->expects($this->once())->method(
'convert')->with(
'someRawValue',
'string', $this->mockConfiguration)->will($this->returnValue(
'convertedValue'));
242 $this->mockPropertyMapper->expects($this->once())->method(
'getMessages')->will($this->returnValue(
new \
TYPO3\CMS\Extbase\Error\Result()));
243 return $this->simpleValueArgument->setValue(
'someRawValue');
253 $this->assertSame(
'convertedValue', $this->simpleValueArgument->getValue());
254 $this->assertTrue($this->simpleValueArgument->isValid());
272 $error = new \TYPO3\CMS\Extbase\Error\Error(
'Some Error', 1234);
273 $mockValidator = $this->getMock(
'TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface', array(
'validate'));
274 $validationMessages = new \TYPO3\CMS\Extbase\Error\Result();
275 $validationMessages->addError($error);
276 $mockValidator->expects($this->once())->method(
'validate')->with(
'convertedValue')->will($this->returnValue($validationMessages));
277 $this->simpleValueArgument->setValidator($mockValidator);
279 $this->assertFalse($this->simpleValueArgument->isValid());
280 $this->assertEquals(array($error), $this->simpleValueArgument->getValidationResults()->getErrors());
288 $this->assertNull($this->simpleValueArgument->getPropertyMappingConfiguration()->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
289 $this->assertNull($this->simpleValueArgument->getPropertyMappingConfiguration()->getConfigurationValue(
'TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \
TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
298 $mockConfigurationManager = $this->getMock(
'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
299 $mockConfigurationManager->expects($this->any())->method(
'isFeatureEnabled')->with(
'rewrittenPropertyMapper')->will($this->returnValue(TRUE));
300 $argument->_set(
'configurationManager', $mockConfigurationManager);
shortNameCanBeRetrievedAgain()
primitiveOrBuiltInObjectsDataTypes()
setValueProvidesFluentInterface()
setValidatorShouldProvideFluentInterfaceAndReallySetValidator()
shortNameShouldThrowExceptionIfInvalid($invalidShortName)
setValueShouldSetValidationErrorsIfValidatorIsSetAndValidationFailed()
setupPropertyMapperAndSetValue()
constructingArgumentWithoutNameThrowsException()
setShortNameProvidesFluentInterface()
enableRewrittenPropertyMapperInArgument(\TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument)
defaultPropertyMappingConfigurationDoesNotAllowCreationOrModificationOfObjects()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
setRequiredShouldProvideFluentInterfaceAndReallySetRequiredState()
validClassNameDataTypes()
setValueShouldCallPropertyMapperCorrectlyAndStoreResultInValue()
setValueUsesMatchingInstanceAsIs()
constructingArgumentWithInvalidNameThrowsException()
setDefaultValueShouldProvideFluentInterfaceAndReallySetDefaultValue()
setValueShouldBeFluentInterface()
passingDataTypeToConstructorReallySetsTheDataType()
$mockConfigurationBuilder