phpunit / phpunit-dom-assertions
DOM assertions for PHPUnit
Installs: 243 599
Dependents: 10
Suggesters: 0
Security: 0
Stars: 28
Watchers: 8
Forks: 15
Open Issues: 1
Requires
- php: ~8.2.0 || ~8.3.0
- ext-dom: *
- phpunit/phpunit: ^10.4.2 || ^11.0.0
- symfony/css-selector: ^6.4.0 || ^7.0.0
- symfony/dom-crawler: ^6.4.0 || ^7.0.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.40.0
- phpstan/phpstan: ^1.10.46
- phpstan/phpstan-deprecation-rules: ^1.1.4
- phpstan/phpstan-phpunit: ^1.3.15
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.