phpunit / phpunit-dom-assertions
DOM assertions for PHPUnit
Installs: 293 637
Dependents: 11
Suggesters: 0
Security: 0
Stars: 29
Watchers: 6
Forks: 13
Open Issues: 1
Requires
- php: ~8.3.0 || ~8.4.0
- ext-dom: *
- phpunit/phpunit: ^10.5.35 || ^11.3.6 || ^12.2.1
- symfony/css-selector: ^6.4.8 || ^7.3.0
- symfony/dom-crawler: ^6.4.12 || ^7.3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75.0
- phpstan/phpstan: ^2.1.17
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0.6
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.