Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / serializer / Tests / Encoder / XmlEncoderTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Serializer\Tests\Encoder;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Serializer\Encoder\XmlEncoder;
16 use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
17 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
18 use Symfony\Component\Serializer\Serializer;
19 use Symfony\Component\Serializer\Tests\Fixtures\Dummy;
20 use Symfony\Component\Serializer\Tests\Fixtures\NormalizableTraversableDummy;
21 use Symfony\Component\Serializer\Tests\Fixtures\ScalarDummy;
22
23 class XmlEncoderTest extends TestCase
24 {
25     /**
26      * @var XmlEncoder
27      */
28     private $encoder;
29
30     private $exampleDateTimeString = '2017-02-19T15:16:08+0300';
31
32     protected function setUp()
33     {
34         $this->encoder = new XmlEncoder();
35         $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder()));
36         $this->encoder->setSerializer($serializer);
37     }
38
39     public function testEncodeScalar()
40     {
41         $obj = new ScalarDummy();
42         $obj->xmlFoo = 'foo';
43
44         $expected = '<?xml version="1.0"?>'."\n".
45             '<response>foo</response>'."\n";
46
47         $this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
48     }
49
50     public function testSetRootNodeName()
51     {
52         $obj = new ScalarDummy();
53         $obj->xmlFoo = 'foo';
54
55         $this->encoder->setRootNodeName('test');
56         $expected = '<?xml version="1.0"?>'."\n".
57             '<test>foo</test>'."\n";
58
59         $this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
60     }
61
62     /**
63      * @expectedException        \Symfony\Component\Serializer\Exception\UnexpectedValueException
64      * @expectedExceptionMessage Document types are not allowed.
65      */
66     public function testDocTypeIsNotAllowed()
67     {
68         $this->encoder->decode('<?xml version="1.0"?><!DOCTYPE foo><foo></foo>', 'foo');
69     }
70
71     public function testAttributes()
72     {
73         $obj = new ScalarDummy();
74         $obj->xmlFoo = array(
75             'foo-bar' => array(
76                 '@id' => 1,
77                 '@name' => 'Bar',
78             ),
79             'Foo' => array(
80                 'Bar' => 'Test',
81                 '@Type' => 'test',
82             ),
83             'föo_bär' => 'a',
84             'Bar' => array(1, 2, 3),
85             'a' => 'b',
86         );
87         $expected = '<?xml version="1.0"?>'."\n".
88             '<response>'.
89             '<foo-bar id="1" name="Bar"/>'.
90             '<Foo Type="test"><Bar>Test</Bar></Foo>'.
91             '<föo_bär>a</föo_bär>'.
92             '<Bar>1</Bar>'.
93             '<Bar>2</Bar>'.
94             '<Bar>3</Bar>'.
95             '<a>b</a>'.
96             '</response>'."\n";
97         $this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
98     }
99
100     public function testElementNameValid()
101     {
102         $obj = new ScalarDummy();
103         $obj->xmlFoo = array(
104             'foo-bar' => 'a',
105             'foo_bar' => 'a',
106             'föo_bär' => 'a',
107         );
108
109         $expected = '<?xml version="1.0"?>'."\n".
110             '<response>'.
111             '<foo-bar>a</foo-bar>'.
112             '<foo_bar>a</foo_bar>'.
113             '<föo_bär>a</föo_bär>'.
114             '</response>'."\n";
115
116         $this->assertEquals($expected, $this->encoder->encode($obj, 'xml'));
117     }
118
119     public function testEncodeSimpleXML()
120     {
121         $xml = simplexml_load_string('<firstname>Peter</firstname>');
122         $array = array('person' => $xml);
123
124         $expected = '<?xml version="1.0"?>'."\n".
125             '<response><person><firstname>Peter</firstname></person></response>'."\n";
126
127         $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
128     }
129
130     public function testEncodeXmlAttributes()
131     {
132         $xml = simplexml_load_string('<firstname>Peter</firstname>');
133         $array = array('person' => $xml);
134
135         $expected = '<?xml version="1.1" encoding="utf-8" standalone="yes"?>'."\n".
136             '<response><person><firstname>Peter</firstname></person></response>'."\n";
137
138         $context = array(
139             'xml_version' => '1.1',
140             'xml_encoding' => 'utf-8',
141             'xml_standalone' => true,
142         );
143
144         $this->assertSame($expected, $this->encoder->encode($array, 'xml', $context));
145     }
146
147     public function testEncodeRemovingEmptyTags()
148     {
149         $array = array('person' => array('firstname' => 'Peter', 'lastname' => null));
150
151         $expected = '<?xml version="1.0"?>'."\n".
152             '<response><person><firstname>Peter</firstname></person></response>'."\n";
153
154         $context = array('remove_empty_tags' => true);
155
156         $this->assertSame($expected, $this->encoder->encode($array, 'xml', $context));
157     }
158
159     public function testEncodeNotRemovingEmptyTags()
160     {
161         $array = array('person' => array('firstname' => 'Peter', 'lastname' => null));
162
163         $expected = '<?xml version="1.0"?>'."\n".
164             '<response><person><firstname>Peter</firstname><lastname/></person></response>'."\n";
165
166         $this->assertSame($expected, $this->encoder->encode($array, 'xml'));
167     }
168
169     public function testContext()
170     {
171         $array = array('person' => array('name' => 'George Abitbol'));
172         $expected = <<<'XML'
173 <?xml version="1.0"?>
174 <response>
175   <person>
176     <name>George Abitbol</name>
177   </person>
178 </response>
179
180 XML;
181
182         $context = array(
183             'xml_format_output' => true,
184         );
185
186         $this->assertSame($expected, $this->encoder->encode($array, 'xml', $context));
187     }
188
189     public function testEncodeScalarRootAttributes()
190     {
191         $array = array(
192             '#' => 'Paul',
193             '@gender' => 'm',
194         );
195
196         $expected = '<?xml version="1.0"?>'."\n".
197             '<response gender="m">Paul</response>'."\n";
198
199         $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
200     }
201
202     public function testEncodeRootAttributes()
203     {
204         $array = array(
205             'firstname' => 'Paul',
206             '@gender' => 'm',
207         );
208
209         $expected = '<?xml version="1.0"?>'."\n".
210             '<response gender="m"><firstname>Paul</firstname></response>'."\n";
211
212         $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
213     }
214
215     public function testEncodeCdataWrapping()
216     {
217         $array = array(
218             'firstname' => 'Paul <or Me>',
219         );
220
221         $expected = '<?xml version="1.0"?>'."\n".
222             '<response><firstname><![CDATA[Paul <or Me>]]></firstname></response>'."\n";
223
224         $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
225     }
226
227     public function testEncodeScalarWithAttribute()
228     {
229         $array = array(
230             'person' => array('@gender' => 'M', '#' => 'Peter'),
231         );
232
233         $expected = '<?xml version="1.0"?>'."\n".
234             '<response><person gender="M">Peter</person></response>'."\n";
235
236         $this->assertEquals($expected, $this->encoder->encode($array, 'xml'));
237     }
238
239     public function testDecodeScalar()
240     {
241         $source = '<?xml version="1.0"?>'."\n".
242             '<response>foo</response>'."\n";
243
244         $this->assertEquals('foo', $this->encoder->decode($source, 'xml'));
245     }
246
247     public function testDecodeBigDigitAttributes()
248     {
249         $source = <<<XML
250 <?xml version="1.0"?>
251 <document index="182077241760011681341821060401202210011000045913000000017100">Name</document>
252 XML;
253
254         $this->assertSame(array('@index' => 182077241760011681341821060401202210011000045913000000017100, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
255     }
256
257     public function testDecodeNegativeIntAttribute()
258     {
259         $source = <<<XML
260 <?xml version="1.0"?>
261 <document index="-1234">Name</document>
262 XML;
263
264         $this->assertSame(array('@index' => -1234, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
265     }
266
267     public function testDecodeFloatAttribute()
268     {
269         $source = <<<XML
270 <?xml version="1.0"?>
271 <document index="-12.11">Name</document>
272 XML;
273
274         $this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
275     }
276
277     public function testDecodeNegativeFloatAttribute()
278     {
279         $source = <<<XML
280 <?xml version="1.0"?>
281 <document index="-12.11">Name</document>
282 XML;
283
284         $this->assertSame(array('@index' => -12.11, '#' => 'Name'), $this->encoder->decode($source, 'xml'));
285     }
286
287     public function testNoTypeCastAttribute()
288     {
289         $source = <<<XML
290 <?xml version="1.0"?>
291 <document a="018" b="-12.11">
292     <node a="018" b="-12.11"/>
293 </document>
294 XML;
295
296         $data = $this->encoder->decode($source, 'xml', array('xml_type_cast_attributes' => false));
297         $expected = array(
298             '@a' => '018',
299             '@b' => '-12.11',
300             'node' => array(
301                 '@a' => '018',
302                 '@b' => '-12.11',
303                 '#' => '',
304             ),
305         );
306         $this->assertSame($expected, $data);
307     }
308
309     public function testEncode()
310     {
311         $source = $this->getXmlSource();
312         $obj = $this->getObject();
313
314         $this->assertEquals($source, $this->encoder->encode($obj, 'xml'));
315     }
316
317     public function testEncodeWithNamespace()
318     {
319         $source = $this->getNamespacedXmlSource();
320         $array = $this->getNamespacedArray();
321
322         $this->assertEquals($source, $this->encoder->encode($array, 'xml'));
323     }
324
325     public function testEncodeSerializerXmlRootNodeNameOption()
326     {
327         $options = array('xml_root_node_name' => 'test');
328         $this->encoder = new XmlEncoder();
329         $serializer = new Serializer(array(), array('xml' => new XmlEncoder()));
330         $this->encoder->setSerializer($serializer);
331
332         $array = array(
333             'person' => array('@gender' => 'M', '#' => 'Peter'),
334         );
335
336         $expected = '<?xml version="1.0"?>'."\n".
337             '<test><person gender="M">Peter</person></test>'."\n";
338
339         $this->assertEquals($expected, $serializer->serialize($array, 'xml', $options));
340     }
341
342     public function testEncodeTraversableWhenNormalizable()
343     {
344         $this->encoder = new XmlEncoder();
345         $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder()));
346         $this->encoder->setSerializer($serializer);
347
348         $expected = <<<'XML'
349 <?xml version="1.0"?>
350 <response><foo>normalizedFoo</foo><bar>normalizedBar</bar></response>
351
352 XML;
353
354         $this->assertEquals($expected, $serializer->serialize(new NormalizableTraversableDummy(), 'xml'));
355     }
356
357     public function testDecode()
358     {
359         $source = $this->getXmlSource();
360         $obj = $this->getObject();
361
362         $this->assertEquals(get_object_vars($obj), $this->encoder->decode($source, 'xml'));
363     }
364
365     public function testDecodeCdataWrapping()
366     {
367         $expected = array(
368             'firstname' => 'Paul <or Me>',
369         );
370
371         $xml = '<?xml version="1.0"?>'."\n".
372             '<response><firstname><![CDATA[Paul <or Me>]]></firstname></response>'."\n";
373
374         $this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
375     }
376
377     public function testDecodeCdataWrappingAndWhitespace()
378     {
379         $expected = array(
380             'firstname' => 'Paul <or Me>',
381         );
382
383         $xml = '<?xml version="1.0"?>'."\n".
384             '<response><firstname>'."\n".
385                 '<![CDATA[Paul <or Me>]]></firstname></response>'."\n";
386
387         $this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
388     }
389
390     public function testDecodeWithNamespace()
391     {
392         $source = $this->getNamespacedXmlSource();
393         $array = $this->getNamespacedArray();
394
395         $this->assertEquals($array, $this->encoder->decode($source, 'xml'));
396     }
397
398     public function testDecodeScalarWithAttribute()
399     {
400         $source = '<?xml version="1.0"?>'."\n".
401             '<response><person gender="M">Peter</person></response>'."\n";
402
403         $expected = array(
404             'person' => array('@gender' => 'M', '#' => 'Peter'),
405         );
406
407         $this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
408     }
409
410     public function testDecodeScalarRootAttributes()
411     {
412         $source = '<?xml version="1.0"?>'."\n".
413             '<person gender="M">Peter</person>'."\n";
414
415         $expected = array(
416             '#' => 'Peter',
417             '@gender' => 'M',
418         );
419
420         $this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
421     }
422
423     public function testDecodeRootAttributes()
424     {
425         $source = '<?xml version="1.0"?>'."\n".
426             '<person gender="M"><firstname>Peter</firstname><lastname>Mac Calloway</lastname></person>'."\n";
427
428         $expected = array(
429             'firstname' => 'Peter',
430             'lastname' => 'Mac Calloway',
431             '@gender' => 'M',
432         );
433
434         $this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
435     }
436
437     public function testDecodeArray()
438     {
439         $source = '<?xml version="1.0"?>'."\n".
440             '<response>'.
441             '<people>'.
442             '<person><firstname>Benjamin</firstname><lastname>Alexandre</lastname></person>'.
443             '<person><firstname>Damien</firstname><lastname>Clay</lastname></person>'.
444             '</people>'.
445             '</response>'."\n";
446
447         $expected = array(
448             'people' => array('person' => array(
449                 array('firstname' => 'Benjamin', 'lastname' => 'Alexandre'),
450                 array('firstname' => 'Damien', 'lastname' => 'Clay'),
451             )),
452         );
453
454         $this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
455     }
456
457     public function testDecodeXMLWithProcessInstruction()
458     {
459         $source = <<<'XML'
460 <?xml version="1.0"?>
461 <?xml-stylesheet type="text/xsl" href="/xsl/xmlverbatimwrapper.xsl"?>
462     <?display table-view?>
463     <?sort alpha-ascending?>
464     <response>
465         <foo>foo</foo>
466         <?textinfo whitespace is allowed ?>
467         <bar>a</bar>
468         <bar>b</bar>
469         <baz>
470             <key>val</key>
471             <key2>val</key2>
472             <item key="A B">bar</item>
473             <item>
474                 <title>title1</title>
475             </item>
476             <?item ignore-title ?>
477             <item>
478                 <title>title2</title>
479             </item>
480             <Barry>
481                 <FooBar id="1">
482                     <Baz>Ed</Baz>
483                 </FooBar>
484             </Barry>
485         </baz>
486         <qux>1</qux>
487     </response>
488     <?instruction <value> ?>
489 XML;
490         $obj = $this->getObject();
491
492         $this->assertEquals(get_object_vars($obj), $this->encoder->decode($source, 'xml'));
493     }
494
495     public function testDecodeIgnoreWhiteSpace()
496     {
497         $source = <<<'XML'
498 <?xml version="1.0"?>
499 <people>
500     <person>
501         <firstname>Benjamin</firstname>
502         <lastname>Alexandre</lastname>
503     </person>
504     <person>
505         <firstname>Damien</firstname>
506         <lastname>Clay</lastname>
507     </person>
508 </people>
509 XML;
510         $expected = array('person' => array(
511             array('firstname' => 'Benjamin', 'lastname' => 'Alexandre'),
512             array('firstname' => 'Damien', 'lastname' => 'Clay'),
513         ));
514
515         $this->assertEquals($expected, $this->encoder->decode($source, 'xml'));
516     }
517
518     public function testDecodeWithoutItemHash()
519     {
520         $obj = new ScalarDummy();
521         $obj->xmlFoo = array(
522             'foo-bar' => array(
523                 '@key' => 'value',
524                 'item' => array('@key' => 'key', 'key-val' => 'val'),
525             ),
526             'Foo' => array(
527                 'Bar' => 'Test',
528                 '@Type' => 'test',
529             ),
530             'föo_bär' => 'a',
531             'Bar' => array(1, 2, 3),
532             'a' => 'b',
533         );
534         $expected = array(
535             'foo-bar' => array(
536                 '@key' => 'value',
537                 'key' => array('@key' => 'key', 'key-val' => 'val'),
538             ),
539             'Foo' => array(
540                 'Bar' => 'Test',
541                 '@Type' => 'test',
542             ),
543             'föo_bär' => 'a',
544             'Bar' => array(1, 2, 3),
545             'a' => 'b',
546         );
547         $xml = $this->encoder->encode($obj, 'xml');
548         $this->assertEquals($expected, $this->encoder->decode($xml, 'xml'));
549     }
550
551     /**
552      * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
553      */
554     public function testDecodeInvalidXml()
555     {
556         $this->encoder->decode('<?xml version="1.0"?><invalid><xml>', 'xml');
557     }
558
559     /**
560      * @expectedException \Symfony\Component\Serializer\Exception\UnexpectedValueException
561      */
562     public function testPreventsComplexExternalEntities()
563     {
564         $this->encoder->decode('<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=XmlEncoderTest.php">]><scan>&test;</scan>', 'xml');
565     }
566
567     public function testDecodeEmptyXml()
568     {
569         if (method_exists($this, 'expectException')) {
570             $this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
571             $this->expectExceptionMessage('Invalid XML data, it can not be empty.');
572         } else {
573             $this->setExpectedException('Symfony\Component\Serializer\Exception\UnexpectedValueException', 'Invalid XML data, it can not be empty.');
574         }
575         $this->encoder->decode(' ', 'xml');
576     }
577
578     protected function getXmlSource()
579     {
580         return '<?xml version="1.0"?>'."\n".
581             '<response>'.
582             '<foo>foo</foo>'.
583             '<bar>a</bar><bar>b</bar>'.
584             '<baz><key>val</key><key2>val</key2><item key="A B">bar</item>'.
585             '<item><title>title1</title></item><item><title>title2</title></item>'.
586             '<Barry><FooBar id="1"><Baz>Ed</Baz></FooBar></Barry></baz>'.
587             '<qux>1</qux>'.
588             '</response>'."\n";
589     }
590
591     protected function getNamespacedXmlSource()
592     {
593         return '<?xml version="1.0"?>'."\n".
594             '<response xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:media="http://search.yahoo.com/mrss/" xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007">'.
595             '<qux>1</qux>'.
596             '<app:foo>foo</app:foo>'.
597             '<yt:bar>a</yt:bar><yt:bar>b</yt:bar>'.
598             '<media:baz><media:key>val</media:key><media:key2>val</media:key2><item key="A B">bar</item>'.
599             '<item><title>title1</title></item><item><title>title2</title></item>'.
600             '<Barry size="large"><FooBar gd:id="1"><Baz>Ed</Baz></FooBar></Barry></media:baz>'.
601             '</response>'."\n";
602     }
603
604     protected function getNamespacedArray()
605     {
606         return array(
607             '@xmlns' => 'http://www.w3.org/2005/Atom',
608             '@xmlns:app' => 'http://www.w3.org/2007/app',
609             '@xmlns:media' => 'http://search.yahoo.com/mrss/',
610             '@xmlns:gd' => 'http://schemas.google.com/g/2005',
611             '@xmlns:yt' => 'http://gdata.youtube.com/schemas/2007',
612             'qux' => '1',
613             'app:foo' => 'foo',
614             'yt:bar' => array('a', 'b'),
615             'media:baz' => array(
616                 'media:key' => 'val',
617                 'media:key2' => 'val',
618                 'A B' => 'bar',
619                 'item' => array(
620                     array(
621                         'title' => 'title1',
622                     ),
623                     array(
624                         'title' => 'title2',
625                     ),
626                 ),
627                 'Barry' => array(
628                     '@size' => 'large',
629                     'FooBar' => array(
630                         'Baz' => 'Ed',
631                         '@gd:id' => 1,
632                     ),
633                 ),
634             ),
635         );
636     }
637
638     protected function getObject()
639     {
640         $obj = new Dummy();
641         $obj->foo = 'foo';
642         $obj->bar = array('a', 'b');
643         $obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1)));
644         $obj->qux = '1';
645
646         return $obj;
647     }
648
649     public function testEncodeXmlWithBoolValue()
650     {
651         $expectedXml = <<<'XML'
652 <?xml version="1.0"?>
653 <response><foo>1</foo><bar>0</bar></response>
654
655 XML;
656
657         $actualXml = $this->encoder->encode(array('foo' => true, 'bar' => false), 'xml');
658
659         $this->assertEquals($expectedXml, $actualXml);
660     }
661
662     public function testEncodeXmlWithDateTimeObjectValue()
663     {
664         $xmlEncoder = $this->createXmlEncoderWithDateTimeNormalizer();
665
666         $actualXml = $xmlEncoder->encode(array('dateTime' => new \DateTime($this->exampleDateTimeString)), 'xml');
667
668         $this->assertEquals($this->createXmlWithDateTime(), $actualXml);
669     }
670
671     public function testEncodeXmlWithDateTimeObjectField()
672     {
673         $xmlEncoder = $this->createXmlEncoderWithDateTimeNormalizer();
674
675         $actualXml = $xmlEncoder->encode(array('foo' => array('@dateTime' => new \DateTime($this->exampleDateTimeString))), 'xml');
676
677         $this->assertEquals($this->createXmlWithDateTimeField(), $actualXml);
678     }
679
680     /**
681      * @return XmlEncoder
682      */
683     private function createXmlEncoderWithDateTimeNormalizer()
684     {
685         $encoder = new XmlEncoder();
686         $serializer = new Serializer(array($this->createMockDateTimeNormalizer()), array('xml' => new XmlEncoder()));
687         $encoder->setSerializer($serializer);
688
689         return $encoder;
690     }
691
692     /**
693      * @return \PHPUnit_Framework_MockObject_MockObject|NormalizerInterface
694      */
695     private function createMockDateTimeNormalizer()
696     {
697         $mock = $this->getMockBuilder('\Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock();
698
699         $mock
700             ->expects($this->once())
701             ->method('normalize')
702             ->with(new \DateTime($this->exampleDateTimeString), 'xml', array())
703             ->willReturn($this->exampleDateTimeString);
704
705         $mock
706             ->expects($this->once())
707             ->method('supportsNormalization')
708             ->with(new \DateTime($this->exampleDateTimeString), 'xml')
709             ->willReturn(true);
710
711         return $mock;
712     }
713
714     /**
715      * @return string
716      */
717     private function createXmlWithDateTime()
718     {
719         return sprintf('<?xml version="1.0"?>
720 <response><dateTime>%s</dateTime></response>
721 ', $this->exampleDateTimeString);
722     }
723
724     /**
725      * @return string
726      */
727     private function createXmlWithDateTimeField()
728     {
729         return sprintf('<?xml version="1.0"?>
730 <response><foo dateTime="%s"/></response>
731 ', $this->exampleDateTimeString);
732     }
733 }