17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
29 protected function setUp()
31 $this->converter = new \TYPO3\CMS\Extbase\Property\TypeConverter\FloatConverter();
39 $this->assertEquals([
'float',
'integer',
'string'], $this->converter->getSupportedSourceTypes(),
'Source types do not match');
40 $this->assertEquals(
'float', $this->converter->getSupportedTargetType(),
'Target type does not match');
41 $this->assertEquals(10, $this->converter->getPriority(),
'Priority does not match');
49 $this->assertSame(1.5, $this->converter->convertFrom(
'1.5',
'float'));
57 $this->assertNull($this->converter->convertFrom(
'',
'float'));
65 $this->assertSame((
float)123, $this->converter->convertFrom(123,
'float'));
73 $mockMappingConfiguration = $this->createMock(\
TYPO3\CMS\
Extbase\Property\PropertyMappingConfigurationInterface::class);
74 $mockMappingConfiguration
75 ->expects($this->at(0))
76 ->method(
'getConfigurationValue')
77 ->with(\
TYPO3\CMS\
Extbase\Property\TypeConverter\FloatConverter::class, \
TYPO3\CMS\
Extbase\Property\TypeConverter\FloatConverter::CONFIGURATION_THOUSANDS_SEPARATOR)
79 $mockMappingConfiguration
80 ->expects($this->at(1))
81 ->method(
'getConfigurationValue')
82 ->with(\
TYPO3\CMS\
Extbase\Property\TypeConverter\FloatConverter::class, \
TYPO3\CMS\
Extbase\Property\TypeConverter\FloatConverter::CONFIGURATION_DECIMAL_POINT)
84 $this->assertSame(1024.42, $this->converter->convertFrom(
'1.024,42',
'float', [], $mockMappingConfiguration));
92 $this->assertInstanceOf(\
TYPO3\CMS\
Extbase\Error\Error::class, $this->converter->convertFrom(
'not numeric',
'float'));
100 $this->assertTrue($this->converter->canConvertFrom(
'1.5',
'float'));
108 $this->assertTrue($this->converter->canConvertFrom(
'',
'integer'));
116 $this->assertTrue($this->converter->canConvertFrom(
null,
'integer'));
124 $this->assertEquals([], $this->converter->getSourceChildPropertiesToBeConverted(
'myString'));