Closed jacekkarczmarczyk closed 4 years ago
Looks it works fine with proper encoding in <meta>
<?php
use PHPUnit\Framework\TestCase;
use Spatie\Snapshots\MatchesSnapshots;
final class SomeTest extends TestCase
{
use MatchesSnapshots;
public function testUtf(): void
{
$this->assertMatchesHtmlSnapshot('<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><p>żółć देवनागरी Кириллица</p>');
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body><p>żółć देवनागरी Кириллица</p></body>
</html>
Following code replaces utf8 characters with html entities in snapshot:
Result:
Maybe
assertMatchesHtmlSnapshot
could accept encoding as a second parameter (it could be passed tonew HtmlDriver($encoding)
and then to$domDocument = new DOMDocument('1.0', $encoding);
?