phpunit/phpunit-dom-assertions

DOM assertions for PHPUnit

v3.3.0 2024-09-25 07:34 UTC

This package is auto-updated.

Last update: 2024-10-25 07:44:26 UTC


README

Latest Stable Version Downloads Integrate

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.