Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit ba20888

Browse files
committed
Adds test validating null values result in content-less tags
Test for #41 Also modifies the docblock of normalizeConstantValue to no longer reference `null` values.
1 parent 13cc944 commit ba20888

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Renderer/XmlRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function createLinkNode(DOMDocument $doc, string $rel, array $data)
9090
}
9191

9292
/**
93-
* Convert true, false, and null to appropriate strings.
93+
* Convert true and false to appropriate strings.
9494
*
9595
* In all other cases, return the value as-is.
9696
*

test/Renderer/XmlRendererTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,16 @@ public function testCanRenderObjectsThatImplementToString()
9595
$xml = $renderer->render($resource);
9696
$this->assertContains((string) $instance, $xml);
9797
}
98+
99+
public function testRendersNullValuesAsTagsWithNoContent()
100+
{
101+
$resource = new HalResource([
102+
'key' => null,
103+
]);
104+
$resource = $resource->withLink(new Link('self', '/example'));
105+
106+
$renderer = new XmlRenderer();
107+
$xml = $renderer->render($resource);
108+
$this->assertContains('<key/>', $xml);
109+
}
98110
}

0 commit comments

Comments
 (0)