phpunit / phpunit-dom-assertions
DOM assertions for PHPUnit
v3.9.0
2026-11-07 08:50 UTC
Requires
- php: ~8.5.0 || ~8.6.0
- ext-dom: *
- phpunit/phpunit: ^11.5.44 || ^12.5.11 || ^13.4.6
- symfony/css-selector: ^7.4.0 || ^8.1.10
- symfony/dom-crawler: ^7.4.0 || ^8.1.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95.29
- phpstan/phpstan: ^2.3.5
- phpstan/phpstan-deprecation-rules: ^2.0.5
- phpstan/phpstan-phpunit: ^2.1.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A work in progress, drop-in replacement for the following deprecated PHPUnit assertions:
assertSelectCount()assertSelectRegExp()assertXPathCount()assertXPathEquals()assertXPathSelectRegExp()assertSelectEquals()
Installation
$ composer require --dev phpunit/phpunit-dom-assertions
Usage
Extend PHPUnit\Framework\DOMTestCase to use the DOM assertions:
namespace My\Tests; use PHPUnit\Framework\DOMAssert; use PHPUnit\Framework\TestCase; final class DOMTest extends TestCase { public function testSelectEquals(): void { $html = file_get_contents('test.html'); $selector = 'span.test_class'; $content = 'Test Class Text'; DOMAssert::assertSelectEquals($selector, $content, true, $html); } }
License
The PHPUnit DOM assertions library is licensed under the BSD 3-Clause license.