File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Ziadoz \AssertableHtml \Tests \Unit \Dom ;
6+
7+ use Dom \Element ;
8+ use Dom \HTMLDocument ;
9+ use Dom \HTMLElement ;
10+ use PHPUnit \Framework \Attributes \DataProvider ;
11+ use PHPUnit \Framework \TestCase ;
12+ use Ziadoz \AssertableHtml \Dom \AssertableElementPromoter ;
13+ use Ziadoz \AssertableHtml \Dom \Elements \AssertableForm ;
14+
15+ class AssertableElementPromoterTest extends TestCase
16+ {
17+ #[DataProvider('promote_data_provider ' )]
18+ public function test_promote (string $ html , string $ class ): void
19+ {
20+ $ this ->assertInstanceOf ($ class , new AssertableElementPromoter ($ this ->getElement ($ html ))->promote ());
21+ }
22+
23+ public static function promote_data_provider (): iterable
24+ {
25+ yield 'form ' => ['<form></form> ' , AssertableForm::class];
26+ }
27+
28+ /*
29+ |--------------------------------------------------------------------------
30+ | Test Helper
31+ |--------------------------------------------------------------------------
32+ */
33+
34+ private function getElement (string $ html ): HTMLElement |Element
35+ {
36+ return HTMLDocument::createFromString ($ html , LIBXML_HTML_NOIMPLIED )->querySelector ('*:first-of-type ' );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments