phpunit/phpunit-dom-assertions

PHPUnit 的 DOM 断言

v3.2.0 2024-02-26 06:28 UTC

This package is auto-updated.

Last update: 2024-09-04 07:31:49 UTC


README

Latest Stable Version Downloads Integrate

正在进行中的工作,以下已弃用的 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 许可协议