11
11
12
12
namespace Symfony \Component \Serializer \Tests \Encoder ;
13
13
14
- use DateTime ;
15
14
use PHPUnit \Framework \TestCase ;
16
15
use Symfony \Component \Serializer \Encoder \XmlEncoder ;
17
16
use Symfony \Component \Serializer \Exception \UnexpectedValueException ;
@@ -29,9 +28,6 @@ class XmlEncoderTest extends TestCase
29
28
*/
30
29
private $ encoder ;
31
30
32
- /**
33
- * @var string
34
- */
35
31
private $ exampleDateTimeString = '2017-02-19T15:16:08+0300 ' ;
36
32
37
33
protected function setUp ()
@@ -535,40 +531,33 @@ protected function getObject()
535
531
return $ obj ;
536
532
}
537
533
538
- /**
539
- * @test
540
- */
541
534
public function testEncodeXmlWithBoolValue ()
542
535
{
543
- $ expectedXml = '<?xml version="1.0"?>
536
+ $ expectedXml = <<<'XML'
537
+ <?xml version="1.0"?>
544
538
<response><foo>1</foo><bar>0</bar></response>
545
- ' ;
539
+
540
+ XML;
546
541
547
542
$ actualXml = $ this ->encoder ->encode (array ('foo ' => true , 'bar ' => false ), 'xml ' );
548
543
549
544
$ this ->assertEquals ($ expectedXml , $ actualXml );
550
545
}
551
546
552
- /**
553
- * @test
554
- */
555
547
public function testEncodeXmlWithDateTimeObjectValue ()
556
548
{
557
549
$ xmlEncoder = $ this ->createXmlEncoderWithDateTimeNormalizer ();
558
550
559
- $ actualXml = $ xmlEncoder ->encode (array ('dateTime ' => new DateTime ($ this ->exampleDateTimeString )), 'xml ' );
551
+ $ actualXml = $ xmlEncoder ->encode (array ('dateTime ' => new \ DateTime ($ this ->exampleDateTimeString )), 'xml ' );
560
552
561
553
$ this ->assertEquals ($ this ->createXmlWithDateTime (), $ actualXml );
562
554
}
563
555
564
- /**
565
- * @test
566
- */
567
556
public function testEncodeXmlWithDateTimeObjectField ()
568
557
{
569
558
$ xmlEncoder = $ this ->createXmlEncoderWithDateTimeNormalizer ();
570
559
571
- $ actualXml = $ xmlEncoder ->encode (array ('foo ' => array ('@dateTime ' => new DateTime ($ this ->exampleDateTimeString ))), 'xml ' );
560
+ $ actualXml = $ xmlEncoder ->encode (array ('foo ' => array ('@dateTime ' => new \ DateTime ($ this ->exampleDateTimeString ))), 'xml ' );
572
561
573
562
$ this ->assertEquals ($ this ->createXmlWithDateTimeField (), $ actualXml );
574
563
}
@@ -595,13 +584,13 @@ private function createMockDateTimeNormalizer()
595
584
$ mock
596
585
->expects ($ this ->once ())
597
586
->method ('normalize ' )
598
- ->with (new DateTime ($ this ->exampleDateTimeString ), 'xml ' , array ())
587
+ ->with (new \ DateTime ($ this ->exampleDateTimeString ), 'xml ' , array ())
599
588
->willReturn ($ this ->exampleDateTimeString );
600
589
601
590
$ mock
602
591
->expects ($ this ->once ())
603
592
->method ('supportsNormalization ' )
604
- ->with (new DateTime ($ this ->exampleDateTimeString ), 'xml ' )
593
+ ->with (new \ DateTime ($ this ->exampleDateTimeString ), 'xml ' )
605
594
->willReturn (true );
606
595
607
596
return $ mock ;
0 commit comments