/** * @test * @dataProvider arrayToStringDataProvider */ public function canConvertFromStringToArray($source, $expectedResult, $mappingConfiguration) { // Create a map of arguments to return values. $configurationValueMap = array(); foreach ($mappingConfiguration as $setting => $value) { $configurationValueMap[] = array('TYPO3\\Flow\\Property\\TypeConverter\\StringConverter', $setting, $value); } $propertyMappingConfiguration = $this->getMock('\\TYPO3\\Flow\\Property\\PropertyMappingConfiguration'); $propertyMappingConfiguration->expects($this->any())->method('getConfigurationValue')->will($this->returnValueMap($configurationValueMap)); $this->assertEquals($expectedResult, $this->converter->convertFrom($source, 'array', array(), $propertyMappingConfiguration)); }
/** * @test */ public function convertFromShouldReturnLocale() { $this->assertInstanceOf(\TYPO3\Flow\I18n\Locale::class, $this->converter->convertFrom('de', 'irrelevant')); }
/** * @test */ public function convertFromReturnsAnErrorIfSpecifiedStringIsNotNumeric() { $this->assertInstanceOf(\TYPO3\Flow\Error\Error::class, $this->converter->convertFrom('not numeric', 'float')); }
/** * @test */ public function convertFromShouldReturnNullForEmptyString() { $source = ''; $result = $this->converter->convertFrom($source, 'TYPO3\\Flow\\Fixtures\\ClassWithSettersAndConstructor'); $this->assertNull($result); }
/** * @test */ public function convertFromReturnsAnErrorIfSpecifiedStringIsNotNumeric() { $this->assertInstanceOf('TYPO3\\Flow\\Error\\Error', $this->converter->convertFrom('not numeric', 'integer')); }
/** * @test */ public function convertFromShouldReturnSourceString() { $this->assertEquals('myString', $this->converter->convertFrom('myString', 'string')); }