File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Spatie \Snapshots \Test \Unit \Drivers ;
4+
5+ use PHPUnit \Framework \TestCase ;
6+ use Spatie \Snapshots \Drivers \HtmlDriver ;
7+ use Spatie \Snapshots \Exceptions \CantBeSerialized ;
8+
9+ class HtmlDriverTest extends TestCase
10+ {
11+ /** @test */
12+ public function it_can_serialize_a_html_string_to_pretty_html ()
13+ {
14+ $ driver = new HtmlDriver ();
15+
16+ $ expected = implode (PHP_EOL , [
17+ '<!DOCTYPE html> ' ,
18+ '<html lang="en"> ' ,
19+ '<head></head> ' ,
20+ '<body><h1>Hello, world!</h1></body> ' ,
21+ '</html> ' ,
22+ '' ,
23+ ]);
24+
25+ $ this ->assertEquals ($ expected , $ driver ->serialize ('<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html> ' ));
26+ }
27+
28+ /** @test */
29+ public function it_can_only_serialize_strings ()
30+ {
31+ $ driver = new HtmlDriver ();
32+
33+ $ this ->expectException (CantBeSerialized::class);
34+
35+ $ driver ->serialize (['foo ' => 'bar ' ]);
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments