This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 9
9
10
10
use DateTime ;
11
11
use PHPUnit \Framework \TestCase ;
12
+ use stdClass ;
12
13
use Zend \Expressive \Hal \HalResource ;
13
14
use Zend \Expressive \Hal \Link ;
14
15
use Zend \Expressive \Hal \Renderer \XmlRenderer ;
16
+ use ZendTest \Expressive \Hal \TestAsset \StringSerializable ;
15
17
16
18
class XmlRendererTest extends TestCase
17
19
{
@@ -80,4 +82,18 @@ public function testCanRenderPhpDateTimeInstances()
80
82
$ xml = $ renderer ->render ($ resource );
81
83
$ this ->assertContains ($ dateTime ->format ('c ' ), $ xml );
82
84
}
85
+
86
+ public function testCanRenderObjectsThatImplementToString ()
87
+ {
88
+ $ instance = new StringSerializable ();
89
+
90
+ $ resource = new HalResource ([
91
+ 'key ' => $ instance ,
92
+ ]);
93
+ $ resource = $ resource ->withLink (new Link ('self ' , '/example ' ));
94
+
95
+ $ renderer = new XmlRenderer ();
96
+ $ xml = $ renderer ->render ($ resource );
97
+ $ this ->assertContains ((string ) $ instance , $ xml );
98
+ }
83
99
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * @see https://github.com/zendframework/zend-expressive-hal for the canonical source repository
4
+ * @copyright Copyright (c) 2017 Zend Technologies USA Inc. (https://www.zend.com)
5
+ * @license https://github.com/zendframework/zend-expressive-hal/blob/master/LICENSE.md New BSD License
6
+ */
7
+
8
+ declare (strict_types=1 );
9
+
10
+ namespace ZendTest \Expressive \Hal \TestAsset ;
11
+
12
+ class StringSerializable
13
+ {
14
+ public function __toString ()
15
+ {
16
+ return __METHOD__ ;
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments