diff --git a/test/Renderer/XmlRendererTest.php b/test/Renderer/XmlRendererTest.php index ed9fd8e..00dca41 100644 --- a/test/Renderer/XmlRendererTest.php +++ b/test/Renderer/XmlRendererTest.php @@ -9,9 +9,11 @@ use DateTime; use PHPUnit\Framework\TestCase; +use stdClass; use Zend\Expressive\Hal\HalResource; use Zend\Expressive\Hal\Link; use Zend\Expressive\Hal\Renderer\XmlRenderer; +use ZendTest\Expressive\Hal\TestAsset\StringSerializable; class XmlRendererTest extends TestCase { @@ -80,4 +82,18 @@ public function testCanRenderPhpDateTimeInstances() $xml = $renderer->render($resource); $this->assertContains($dateTime->format('c'), $xml); } + + public function testCanRenderObjectsThatImplementToString() + { + $instance = new StringSerializable(); + + $resource = new HalResource([ + 'key' => $instance, + ]); + $resource = $resource->withLink(new Link('self', '/example')); + + $renderer = new XmlRenderer(); + $xml = $renderer->render($resource); + $this->assertContains((string) $instance, $xml); + } } diff --git a/test/TestAsset/StringSerializable.php b/test/TestAsset/StringSerializable.php new file mode 100644 index 0000000..85edffe --- /dev/null +++ b/test/TestAsset/StringSerializable.php @@ -0,0 +1,18 @@ +