Skip to content

Commit 5893d24

Browse files
committed
add html driver unittest
1 parent 788b8a3 commit 5893d24

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

0 commit comments

Comments
 (0)