phpunit / phpunit-dom-assertions
PHPUnit 的 DOM 断言
v3.2.0
2024-02-26 06:28 UTC
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
正在进行中的工作,以下已弃用的 PHPUnit 断言的替换品
assertSelectCount()
assertSelectRegExp()
assertXPathCount()
assertXPathEquals()
assertXPathSelectRegExp()
assertSelectEquals()
安装
$ composer require --dev phpunit/phpunit-dom-assertions
用法
扩展 PHPUnit\Framework\DOMTestCase
以使用 DOM 断言
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); } }
许可协议
PHPUnit DOM 断言库采用 BSD 3-Clause 许可协议。