Skip to content

Commit fd47a17

Browse files
committed
Add missing tests to cover changed / enhanced functionality
1 parent 5657483 commit fd47a17

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tests/document/DocumentCollectionTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
#[Small]
1414
class DocumentCollectionTest extends TestCase {
1515

16+
public function testIsInitiallyEmpty(): void {
17+
$this->assertTrue(
18+
(new DocumentCollection())->isEmpty()
19+
);
20+
}
21+
1622
public function testIteratesOverDocuments(): void {
1723

1824
$documents = [];
@@ -44,6 +50,7 @@ public function testCanAddDocument(): void {
4450

4551
$this->assertContains($document, $collection);
4652
$this->assertCount(2, $collection);
53+
$this->assertFalse($collection->isEmpty());
4754
}
4855

4956
public function testAssocArrayLoosesKeyCorrectly(): void {

tests/serializer/HTMLSerializerTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,32 @@ public function testNoRedundantNamespacesAreCreated(): void {
217217
);
218218
}
219219

220+
public function testRedundantWhitespaceOnTextNodesGetsTrimmed(): void {
221+
$dom = new DOMDocument();
222+
$dom->preserveWhiteSpace = true;
223+
$dom->loadXML(
224+
'<html xmlns="http://www.w3.org/1999/xhtml">
225+
226+
227+
<p />
228+
229+
230+
</html>
231+
');
232+
233+
$expected = implode("\n", [
234+
'<html xmlns="http://www.w3.org/1999/xhtml">',
235+
' <p></p>',
236+
'</html>' . "\n"
237+
]);
238+
239+
$this->assertSame(
240+
$expected,
241+
(new HTMLSerializer())->noHtml5Doctype()->serialize($dom)
242+
);
243+
244+
}
245+
220246

221247
private function createInputDocument(): Document {
222248
return Document::fromString(file_get_contents(__DIR__ . '/../_data/serializer/input.xml'));

0 commit comments

Comments
 (0)