Skip to content

Commit a2daeaf

Browse files
committed
test promote
1 parent b5934b7 commit a2daeaf

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

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

0 commit comments

Comments
 (0)