Skip to content

Commit

Permalink
PHP 7.3 keeps some more whitespaces in DOMDocument
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Nov 11, 2018
1 parent 8a2b862 commit 9103871
Showing 1 changed file with 51 additions and 21 deletions.
72 changes: 51 additions & 21 deletions tests/FluentDOM/Loader/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,24 @@ public function testLoadWithMultiByteHtmlDefinedByMetaTag() {
Options::ENCODING => 'ascii'
]
);
$this->assertEquals(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta charset="utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n",
$result->getDocument()->saveHTML()
$this->assertThat(
$result->getDocument()->saveHTML(),
$this->logicalOr(
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta charset="utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n"
),
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'.
'<head><meta charset="utf-8"></head>'.
'<body>你好,世界</body>'.
'</html>'."\n"
)
)
);
}

Expand All @@ -323,13 +334,24 @@ public function testLoadWithMultiByteHtmlDefinedByDeprecatedMetaTag() {
Options::ENCODING => 'ascii'
]
);
$this->assertEquals(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n",
$result->getDocument()->saveHTML()
$this->assertThat(
$result->getDocument()->saveHTML(),
$this->logicalOr(
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n"
),
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'.
'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>'.
'<body>你好,世界</body>'.
'</html>'."\n"
)
)
);
}

Expand Down Expand Up @@ -373,13 +395,21 @@ public function testLoadWithMultiByteHtmlReplaceExistingPi() {
Options::FORCE_ENCODING => true
]
);
$this->assertEquals(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta charset="utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n",
$result->getDocument()->saveHTML()
$this->assertThat(
$result->getDocument()->saveHTML(),
$this->logicalOr(
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html>'."\n".
'<head><meta charset="utf-8"></head>'."\n".
'<body>你好,世界</body>'."\n".
'</html>'."\n"
),
$this->equalTo(
'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'."\n".
'<html><head><meta charset="utf-8"></head><body>你好,世界</body></html>'."\n"
)
)
);
}
}
Expand Down

0 comments on commit 9103871

Please sign in to comment.