/** * @test * @dataProvider arrayToStringDataProvider */ public function canConvertFromStringToArray($source, $expectedResult, $mappingConfiguration) { // Create a map of arguments to return values. $configurationValueMap = []; foreach ($mappingConfiguration as $setting => $value) { $configurationValueMap[] = [StringConverter::class, $setting, $value]; } $propertyMappingConfiguration = $this->createMock(PropertyMappingConfiguration::class); $propertyMappingConfiguration->expects($this->any())->method('getConfigurationValue')->will($this->returnValueMap($configurationValueMap)); $this->assertEquals($expectedResult, $this->converter->convertFrom($source, 'array', [], $propertyMappingConfiguration)); }
/** * @test */ public function getSourceChildPropertiesToBeConvertedShouldReturnEmptyArray() { $this->assertEmpty($this->converter->getSourceChildPropertiesToBeConverted('something')); }
/** * @test */ public function convertFromShouldReturnNullForEmptyString() { $source = ''; $result = $this->converter->convertFrom($source, ClassWithSettersAndConstructor::class); $this->assertNull($result); }
/** * @test */ public function getSourceChildPropertiesToBeConvertedShouldReturnEmptyArray() { $this->assertEquals([], $this->converter->getSourceChildPropertiesToBeConverted('myString')); }