File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 20
20
"prefer-stable" : true ,
21
21
"require" : {
22
22
"php" : " ^7.4|^8.0" ,
23
+ "ext-dom" : " *" ,
23
24
"psr/http-message" : " ^1.0" ,
24
25
"psr/http-server-middleware" : " ^1.0" ,
25
26
"yiisoft/http" : " ^1.0" ,
Original file line number Diff line number Diff line change @@ -541,6 +541,35 @@ public function testItemTagWhenNameIsEmptyOrInvalid(): void
541
541
);
542
542
}
543
543
544
+ public function testObjectWithPublicProperties (): void
545
+ {
546
+ $ object = new class () {
547
+ public int $ x = 7 ;
548
+ public float $ y = 42 ;
549
+ public string $ name = 'yii ' ;
550
+ protected int $ a = 1 ;
551
+ private int $ b = 2 ;
552
+ };
553
+ $ dataResponse = $ this ->createResponse ($ object );
554
+ $ result = (new XmlDataResponseFormatter ())->format ($ dataResponse );
555
+ $ result ->getBody ()->rewind ();
556
+
557
+ $ this ->assertSame (
558
+ $ this ->xml (
559
+ <<<EOF
560
+ <response>
561
+ <item>
562
+ <x>7</x>
563
+ <y>42</y>
564
+ <name>yii</name>
565
+ </item>
566
+ </response>
567
+ EOF
568
+ ),
569
+ $ result ->getBody ()->getContents ()
570
+ );
571
+ }
572
+
544
573
private function createResponse ($ data ): DataResponse
545
574
{
546
575
return (new DataResponseFactory (new Psr17Factory ()))->createResponse ($ data );
You can’t perform that action at this time.
0 commit comments