phpunit / phpunit-dom-assertions
DOM assertions for PHPUnit
Installs: 253 061
Dependents: 10
Suggesters: 0
Security: 0
Stars: 28
Watchers: 8
Forks: 15
Open Issues: 1
Requires
- php: ~8.3.0 || ~8.4.0
- ext-dom: *
- phpunit/phpunit: ^10.5.35 || ^11.3.6
- symfony/css-selector: ^6.4.8 || ^7.1.1
- symfony/dom-crawler: ^6.4.12 || ^7.1.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64.0
- phpstan/phpstan: ^1.12.4
- phpstan/phpstan-deprecation-rules: ^1.2.1
- phpstan/phpstan-phpunit: ^1.4.0
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.