Skip to content

Commit 4ee06e3

Browse files
authored
Merge pull request #144 from mallardduck/prevent-html-serialize-regression
Add test to cover HTML without doctype
2 parents 90b853f + 56ee1a0 commit 4ee06e3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"php": "^7.3|^7.4|^8.0",
2424
"ext-dom": "*",
2525
"ext-json": "*",
26+
"ext-libxml": "*",
2627
"composer-runtime-api": "^2.0",
2728
"phpunit/phpunit": "^8.3|^9.0",
2829
"symfony/property-access": "^4.0|^5.0|^6.0",

tests/Unit/Drivers/HtmlDriverTest.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function it_can_serialize_a_html_string_to_pretty_html()
2424

2525
$this->assertEquals($expected, $driver->serialize('<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html>'));
2626
}
27-
27+
2828
/** @test */
2929
public function test_for_issue_140()
3030
{
@@ -46,6 +46,22 @@ public function test_for_issue_140()
4646
$this->assertEquals($expected, $driver->serialize($expected));
4747
}
4848

49+
/** @test */
50+
public function it_can_serialize_a_html_string_without_a_doctype()
51+
{
52+
$driver = new HtmlDriver();
53+
54+
$expected = implode("\n", [
55+
'<html lang="en">',
56+
'<head></head>',
57+
'<body><h1>Hello, world!</h1></body>',
58+
'</html>',
59+
'',
60+
]);
61+
62+
$this->assertEquals($expected, $driver->serialize('<html lang="en"><head></head><body><h1>Hello, world!</h1></body></html>'));
63+
}
64+
4965
/** @test */
5066
public function it_can_only_serialize_strings()
5167
{

0 commit comments

Comments
 (0)