Skip to content

Commit

Permalink
Add missing tests to cover changed / enhanced functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Apr 3, 2024
1 parent 5657483 commit fd47a17
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/document/DocumentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#[Small]
class DocumentCollectionTest extends TestCase {

public function testIsInitiallyEmpty(): void {
$this->assertTrue(
(new DocumentCollection())->isEmpty()
);
}

public function testIteratesOverDocuments(): void {

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

$this->assertContains($document, $collection);
$this->assertCount(2, $collection);
$this->assertFalse($collection->isEmpty());
}

public function testAssocArrayLoosesKeyCorrectly(): void {
Expand Down
26 changes: 26 additions & 0 deletions tests/serializer/HTMLSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,32 @@ public function testNoRedundantNamespacesAreCreated(): void {
);
}

public function testRedundantWhitespaceOnTextNodesGetsTrimmed(): void {
$dom = new DOMDocument();
$dom->preserveWhiteSpace = true;
$dom->loadXML(
'<html xmlns="http://www.w3.org/1999/xhtml">
<p />
</html>
');

$expected = implode("\n", [
'<html xmlns="http://www.w3.org/1999/xhtml">',
' <p></p>',
'</html>' . "\n"
]);

$this->assertSame(
$expected,
(new HTMLSerializer())->noHtml5Doctype()->serialize($dom)
);

}


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

0 comments on commit fd47a17

Please sign in to comment.