/** * @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\FLOW3\Property\PropertyMappingConfiguration(); $configuration->setTypeConverterOptions('TYPO3\\FLOW3\\Property\\TypeConverter\\ObjectConverter', array()); $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration)); }
/** * @param array $typeConverterOptions * @return \TYPO3\FLOW3\Property\PropertyMappingConfiguration */ protected function buildConfiguration($typeConverterOptions) { $configuration = new \TYPO3\FLOW3\Property\PropertyMappingConfiguration(); $configuration->setTypeConverterOptions('TYPO3\\FLOW3\\Property\\TypeConverter\\PersistentObjectConverter', $typeConverterOptions); return $configuration; }
/** * @test * @expectedException TYPO3\FLOW3\I18n\Exception\InvalidLocaleIdentifierException */ public function convertFromThrowsExceptionIfLocaleIsInvalid() { $configuration = new \TYPO3\FLOW3\Property\PropertyMappingConfiguration(); $configuration->setTypeConverterOption('TYPO3\\FLOW3\\Property\\TypeConverter\\FloatConverter', 'locale', 'some-non-existent-locale-identifier'); $this->converter->convertFrom('84,42', 'float', array(), $configuration); }
/** * @test */ public function convertFromProperlyConvertsArrayWithDateAsArray() { $source = array('day' => '13', 'month' => '10', 'year' => '2010'); $mappingConfiguration = new \TYPO3\FLOW3\Property\PropertyMappingConfiguration(); $mappingConfiguration->setTypeConverterOption('TYPO3\\FLOW3\\Property\\TypeConverter\\DateTimeConverter', \TYPO3\FLOW3\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, 'Y-m-d'); $date = $this->converter->convertFrom($source, 'DateTime', array(), $mappingConfiguration); $actualResult = $date->format('Y-m-d'); $this->assertSame('2010-10-13', $actualResult); }