function Braintree_Xml_ParserTest::testTypeCastsDatetimes in Commerce Braintree 7
File
- braintree_php/
tests/ unit/ Xml_ParserTest.php, line 41
Class
Code
function testTypeCastsDatetimes() {
$xml = <<<XML
<root>
<created-at type="datetime">2009-10-28T10:19:49Z</created-at>
</root>
XML;
$array = Braintree_Xml::buildArrayFromXml($xml);
date_default_timezone_set('UTC');
$dateTime = new DateTime('2009-10-28T10:19:49', new DateTimeZone('UTC'));
$this
->assertEquals(array(
'root' => array(
'createdAt' => $dateTime,
),
), $array);
$this
->assertType('DateTime', $array['root']['createdAt']);
}