baxtian / dom-assert
Assert library for PHPUnit for testing DOM trees.
0.3.2
2025-04-03 00:44 UTC
Requires
- php: >=7.0
- phpunit/phpunit: ^9.6
- voku/simple_html_dom: ^4.8
README
This is an Assert library for PHPUnit for testing DOM trees.
Usage:
<?php
namespace Tests;
use PHPUnit\Framework\TestCase;
use Baxtian\DOMAssert;
class DomTest extends TestCase
{
public function testShortcode(): void
{
$html = "<div><p class='answer black'>All good!</p><p id='greetings' data-greetings='Hi!'>Second paragraph</p></div>";
DOMAssert::assertNodeText($html, 'p.answer', 'All good!');
DOMAssert::assertNodeHasClass($html, 'p.answer', 'black');
DOMAssert::assertNodeCount($html, 'p', 2);
DOMAssert::assertNodeHasAttribute($html, 'p#greetings', 'data-greetings', 'Hi!');
}
}
Mantainers
Juan Sebastián Echeverry baxtian.echeverry@gmail.com
Changelog
0.3.2
- First stable release