Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d9bc76dfc3
@ -32,6 +32,10 @@ class DateTimeTypeConverter implements TypeConverterInterface
|
||||
$doc = new \DOMDocument();
|
||||
$doc->loadXML($data);
|
||||
|
||||
if ('' === $doc->textContent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new \DateTime($doc->textContent);
|
||||
}
|
||||
|
||||
@ -39,4 +43,5 @@ class DateTimeTypeConverter implements TypeConverterInterface
|
||||
{
|
||||
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,10 @@ class DateTypeConverter implements TypeConverterInterface
|
||||
$doc = new \DOMDocument();
|
||||
$doc->loadXML($data);
|
||||
|
||||
if ('' === $doc->textContent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new \DateTime($doc->textContent);
|
||||
}
|
||||
|
||||
@ -40,3 +44,4 @@ class DateTypeConverter implements TypeConverterInterface
|
||||
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,4 +40,15 @@ class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('<dateTime>2002-10-10T12:00:00-05:00</dateTime>', $dateXml);
|
||||
}
|
||||
}
|
||||
|
||||
public function testConvertNullDateTimeXmlToPhp()
|
||||
{
|
||||
$converter = new DateTimeTypeConverter();
|
||||
|
||||
$dateXml = '<sometag xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>';
|
||||
$date = $converter->convertXmlToPhp($dateXml);
|
||||
|
||||
$this->assertNull($date);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,4 +38,15 @@ class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('<date>2002-10-10</date>', $dateXml);
|
||||
}
|
||||
}
|
||||
|
||||
public function testConvertNullDateTimeXmlToPhp()
|
||||
{
|
||||
$converter = new DateTypeConverter();
|
||||
|
||||
$dateXml = '<sometag xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>';
|
||||
$date = $converter->convertXmlToPhp($dateXml);
|
||||
|
||||
$this->assertNull($date);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user