/** * @param mixed $data * @return mixed * @throws Exception */ public function conduct($data) { $targetType = $this->getTargetType(); $typeConverter = $this->getTypeConverter(); if (FALSE === $typeConverter->canConvertFrom($data, $targetType)) { throw new Exception('TypeConverter ' . get_class($typeConverter) . ' cannot convert ' . gettype($data) . ' to ' . $targetType, 1386292424); } $output = $this->typeConverter->convertFrom($data, $targetType); if (TRUE === $output instanceof Error) { throw new Exception('Conversion of ' . gettype($data) . ' to ' . $targetType . ' was unsuccessful, Error was: ' . $output->getMessage(), $output->getCode()); } return $output; }
/** * @test */ public function convertFromShouldReturnNullForEmptyString() { $source = ''; $result = $this->converter->convertFrom($source, 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\ClassWithSettersAndConstructor'); $this->assertNull($result); }
/** * @test */ public function getSourceChildPropertiesToBeConvertedShouldReturnEmptyArray() { $this->assertEquals(array(), $this->converter->getSourceChildPropertiesToBeConverted('myString')); }