@@ -54,6 +54,21 @@ public function it_can_create_a_snapshot_from_an_array()
5454 );
5555 }
5656
57+ /** @test */
58+ public function it_can_create_a_snapshot_from_html ()
59+ {
60+ $ mockTrait = $ this ->getMatchesSnapshotMock ();
61+
62+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait , function ($ mockTrait ) {
63+ $ mockTrait ->assertMatchesHtmlSnapshot ('<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html> ' );
64+ });
65+
66+ $ this ->assertSnapshotMatchesExample (
67+ 'MatchesSnapshotTest__it_can_create_a_snapshot_from_html__1.html ' ,
68+ 'snapshot.html '
69+ );
70+ }
71+
5772 /** @test */
5873 public function it_can_create_a_snapshot_from_xml ()
5974 {
@@ -107,6 +122,14 @@ public function it_can_match_an_existing_string_snapshot()
107122 $ mockTrait ->assertMatchesSnapshot ('Foo ' );
108123 }
109124
125+ /** @test */
126+ public function it_can_match_an_existing_html_snapshot ()
127+ {
128+ $ mockTrait = $ this ->getMatchesSnapshotMock ();
129+
130+ $ mockTrait ->assertMatchesHtmlSnapshot ('<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html> ' );
131+ }
132+
110133 /** @test */
111134 public function it_can_match_an_existing_xml_snapshot ()
112135 {
@@ -141,6 +164,16 @@ public function it_can_mismatch_a_string_snapshot()
141164 $ mockTrait ->assertMatchesSnapshot ('Bar ' );
142165 }
143166
167+ /** @test */
168+ public function it_can_mismatch_a_html_snapshot ()
169+ {
170+ $ mockTrait = $ this ->getMatchesSnapshotMock ();
171+
172+ $ this ->expectFailedMatchesSnapshotTest ();
173+
174+ $ mockTrait ->assertMatchesHtmlSnapshot ('<!doctype html><html lang="en"><head></head><body><h1>Hallo welt!</h1></body></html> ' );
175+ }
176+
144177 /** @test */
145178 public function it_can_mismatch_a_xml_snapshot ()
146179 {
@@ -257,6 +290,23 @@ public function it_can_update_a_string_snapshot()
257290 );
258291 }
259292
293+ /** @test */
294+ public function it_can_update_a_html_snapshot ()
295+ {
296+ $ _SERVER ['argv ' ][] = '--update-snapshots ' ;
297+
298+ $ mockTrait = $ this ->getMatchesSnapshotMock ();
299+
300+ $ this ->expectIncompleteMatchesSnapshotTest ($ mockTrait , function ($ mockTrait ) {
301+ $ mockTrait ->assertMatchesHtmlSnapshot ('<!doctype html><html lang="en"><head></head><body><h1>Hello, world!</h1></body></html> ' );
302+ });
303+
304+ $ this ->assertSnapshotMatchesExample (
305+ 'MatchesSnapshotTest__it_can_update_a_html_snapshot__1.html ' ,
306+ 'snapshot.html '
307+ );
308+ }
309+
260310 /** @test */
261311 public function it_can_update_a_xml_snapshot ()
262312 {
@@ -355,7 +405,7 @@ private function expectFailedMatchesSnapshotTest()
355405 }
356406
357407 /**
358- * @return \PHPUnit\Framework\MockObject\MockObject
408+ * @return \PHPUnit\Framework\MockObject\MockObject|\Spatie\Snapshots\MatchesSnapshots
359409 */
360410 private function getMatchesSnapshotMock (): MockObject
361411 {
0 commit comments