Ejemplo n.º 1
0
 /**
  * @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\CMS\Extbase\Property\PropertyMappingConfiguration();
     $configuration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\ObjectConverter', array());
     $this->assertEquals('TheTypeOfSubObject', $this->converter->getTypeOfChildProperty('TheTargetType', 'thePropertyName', $configuration));
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function convertSkipsUnknownPropertiesIfConfiguredTo()
 {
     $source = array('firstProperty' => 1, 'secondProperty' => 2);
     $typeConverters = array('array' => array('stdClass' => array(10 => $this->getMockTypeConverter('array2object', true, $source, 'integer'))), 'integer' => array('integer' => array(10 => $this->getMockTypeConverter('integer2integer'))));
     $configuration = new \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration();
     $propertyMapper = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Property\PropertyMapper::class, array('dummy'));
     $propertyMapper->_set('typeConverters', $typeConverters);
     $propertyMapper->convert($source, 'stdClass', $configuration->allowProperties('firstProperty')->skipUnknownProperties());
 }
 /**
  * @param array $typeConverterOptions
  * @return \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
  */
 protected function buildConfiguration($typeConverterOptions)
 {
     $configuration = new \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration();
     $configuration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', $typeConverterOptions);
     return $configuration;
 }
Ejemplo n.º 4
0
 /**
  * @test
  */
 public function convertFromProperlyConvertsArrayWithDateAsArray()
 {
     $source = array('day' => '13', 'month' => '10', 'year' => '2010');
     $mappingConfiguration = new \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration();
     $mappingConfiguration->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, \TYPO3\CMS\Extbase\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);
 }