Neos\Flow\Tests\Unit\Property\TypeConverter\DateTimeConverterTest::convertFromArrayTests PHP Method

convertFromArrayTests() public method

public convertFromArrayTests ( array $source, boolean $isValid )
$source array the array to be converted
$isValid boolean TRUE if the conversion is expected to be successful, otherwise FALSE
    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));
    }