Skip to content

Commit

Permalink
Add test to ensure stripping RDFa doesn't remove other attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Dec 2, 2023
1 parent f646459 commit b5b79f9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/serializer/HTMLSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use function file_get_contents;
use function implode;
use const LIBXML_NOEMPTYTAG;

Expand Down Expand Up @@ -48,6 +49,23 @@ public function testStripsRDFaIfRequested() {
);
}

public function testStrippingRDFaKeepsFollowingAttributes() {
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadXML('<?xml version="1.0" encoding="ISO-8859-1" ?><html xmlns="http://www.w3.org/1999/xhtml" property="a" some="attr" />');

$expected = implode("\n", [
'<?xml version="1.0" encoding="ISO-8859-1"?>',
'<html xmlns="http://www.w3.org/1999/xhtml" some="attr"></html>' . "\n"
]);

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


public function testSerializesDocumentWithoutCleaningIfRequested() {
$this->assertSame(
file_get_contents(__DIR__ . '/../_data/serializer/nocleaning.html'),
Expand Down Expand Up @@ -143,6 +161,7 @@ public function testEncodingGetSerializedCorrectly() {
(new HTMLSerializer())->keepXMLHeader()->noHtml5Doctype()->disableNamespaceCleaning()->serialize($dom),
'Using DOM SaveXML'
);

}


Expand Down

0 comments on commit b5b79f9

Please sign in to comment.