phpunit / phpunit-dom-assertions
DOM assertions for PHPUnit
Installs: 313 557
Dependents: 12
Suggesters: 0
Security: 0
Stars: 29
Watchers: 5
Forks: 13
Open Issues: 1
pkg:composer/phpunit/phpunit-dom-assertions
Requires
- php: ~8.4.0 || ~8.5.0
- ext-dom: *
- phpunit/phpunit: ^10.5.58 || ^11.5.42 || ^12.4.1
- symfony/css-selector: ^6.4.24 || ^7.3.0
- symfony/dom-crawler: ^6.4.25 || ^7.3.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89.0
- phpstan/phpstan: ^2.1.31
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0.7
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.