Neos\Flow\Tests\Unit\Property\TypeConverter\DateTimeConverterTest::convertFromStringTests PHP Метод

convertFromStringTests() публичный Метод

public convertFromStringTests ( string $source, string $dateFormat, boolean $isValid )
$source string the string to be converted
$dateFormat string the expected date format
$isValid boolean TRUE if the conversion is expected to be successful, otherwise FALSE
    public function convertFromStringTests($source, $dateFormat, $isValid)
    {
        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;
        }
        $this->assertSame($source, $date->format($dateFormat));
    }