All Type Converters should have NO INTERNAL STATE, such that they can be used as singletons and multiple times in succession (as this improves performance dramatically).
コード例 #1
0
 /**
  * @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));
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #4
0
 /**
  * @test
  */
 public function getSourceChildPropertiesToBeConvertedShouldReturnEmptyArray()
 {
     $this->assertEquals([], $this->converter->getSourceChildPropertiesToBeConverted('myString'));
 }