public function convertFromArrayTests(array $source, $isValid)
{
$dateFormat = isset($source['dateFormat']) && strlen($source['dateFormat']) > 0 ? $source['dateFormat'] : null;
if ($dateFormat !== null) {
$mockMappingConfiguration = $this->createMock(PropertyMappingConfigurationInterface::class);
$mockMappingConfiguration->expects($this->atLeastOnce())->method('getConfigurationValue')->with(DateTimeConverter::class, DateTimeConverter::CONFIGURATION_DATE_FORMAT)->will($this->returnValue($dateFormat));
} else {
$mockMappingConfiguration = null;
}
$date = $this->converter->convertFrom($source, 'DateTime', [], $mockMappingConfiguration);
if ($isValid !== true) {
$this->assertInstanceOf(FlowError::class, $date);
return;
}
$this->assertInstanceOf(\DateTime::class, $date);
if ($dateFormat === null) {
$dateFormat = DateTimeConverter::DEFAULT_DATE_FORMAT;
}
$dateAsString = isset($source['date']) ? strval($source['date']) : '';
$this->assertSame($dateAsString, $date->format($dateFormat));
}