public function testEscapingSpecialChars() { $expected = <<<XML <?xml version="1.0" encoding="UTF-8"?> <root> <stuff><>&'"</stuff> </root> XML; $xml = Braintree\Xml::buildXmlFromArray(['root' => ['stuff' => '<>&\'"']]); $this->assertEquals($expected, $xml); }
public function testDoesNotModifyDateTime() { $date = new \DateTime(); $date->setTimestamp(strtotime('2016-05-17T21:22:26Z')); $date->setTimezone(new \DateTimeZone('Europe/Paris')); $originalDate = clone $date; $expected = <<<XML <?xml version="1.0" encoding="UTF-8"?> <root> <stuff type="datetime">2016-05-17T21:22:26Z</stuff> </root> XML; $xml = Braintree\Xml::buildXmlFromArray(['root' => ['stuff' => $date]]); $this->assertEquals($originalDate, $date); $this->assertEquals($expected, $xml); }
public function testIncludesTheEncodingRoundtrip() { $array = ['root' => ['root' => 'bar']]; $xml = Braintree\Xml::buildXmlFromArray($array); $this->assertRegExp('<\\?xml version=\\"1.0\\" encoding=\\"UTF-8\\"\\?>', $xml); }
private function _buildXml($params) { return empty($params) ? null : Xml::buildXmlFromArray($params); }