66
77use function Flow \Types \DSL \{type_from_array , type_html };
88use Flow \Types \Exception \{CastingException , InvalidTypeException };
9+ use Flow \Types \Value \HTMLDocument ;
910use PHPUnit \Framework \Attributes \DataProvider ;
1011use PHPUnit \Framework \TestCase ;
1112
1213final class HTMLTypeTest extends TestCase
1314{
1415 public static function assert_data_provider () : \Generator
1516 {
16- yield 'valid \DOMDocument ' => [
17- 'value ' => new \ DOMDocument ,
17+ yield 'valid HTMLDocument ' => [
18+ 'value ' => new HTMLDocument ( '' ) ,
1819 'exceptionClass ' => null ,
1920 ];
2021
@@ -66,7 +67,6 @@ public static function cast_data_provider() : \Generator
6667 'expected ' => <<<'HTML'
6768<!DOCTYPE html>
6869<html lang="en"><body><div><span>1</span></div></body></html>
69-
7070HTML,
7171 'exceptionClass ' => null ,
7272 ];
@@ -75,7 +75,6 @@ public static function cast_data_provider() : \Generator
7575 'value ' => '<div><span>1</span></div> ' ,
7676 'expected ' => <<<'HTML'
7777<div><span>1</span></div>
78-
7978HTML,
8079 'exceptionClass ' => null ,
8180 ];
@@ -89,8 +88,8 @@ public static function cast_data_provider() : \Generator
8988
9089 public static function is_valid_data_provider () : \Generator
9190 {
92- yield 'valid \DOMDocument ' => [
93- 'value ' => new \ DOMDocument ( ),
91+ yield 'valid HTMLDocument ' => [
92+ 'value ' => new HTMLDocument ( '' ),
9493 'expected ' => true ,
9594 ];
9695
@@ -117,7 +116,7 @@ public function test_assert(mixed $value, ?string $exceptionClass = null) : void
117116 $ this ->expectException ($ exceptionClass );
118117 type_html ()->assert ($ value );
119118 } else {
120- self ::assertInstanceOf (\DOMDocument ::class, type_html ()->assert ($ value ));
119+ self ::assertInstanceOf (HTMLDocument ::class, type_html ()->assert ($ value ));
121120 }
122121 }
123122
@@ -129,7 +128,7 @@ public function test_cast(mixed $value, mixed $expected, ?string $exceptionClass
129128 type_html ()->cast ($ value );
130129 } else {
131130 $ result = type_html ()->cast ($ value );
132- self ::assertSame ($ expected , $ result ->saveHtml ());
131+ self ::assertSame ($ expected , $ result ->toString ());
133132 }
134133 }
135134
0 commit comments