PHPackages                             phpunit/phpunit-dom-assertions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpunit/phpunit-dom-assertions

ActiveLibrary[Testing &amp; Quality](/categories/testing)

phpunit/phpunit-dom-assertions
==============================

DOM assertions for PHPUnit

v3.8.0(3mo ago)29343.5k↑12.3%13[1 issues](https://github.com/lstrojny/phpunit-dom-assertions/issues)11MITPHPPHP ~8.4.0 || ~8.5.0CI passing

Since Nov 24Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/lstrojny/phpunit-dom-assertions)[ Packagist](https://packagist.org/packages/phpunit/phpunit-dom-assertions)[ Docs](https://github.com/lstrojny/phpunit-dom-assertions)[ RSS](/packages/phpunit-phpunit-dom-assertions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (20)Used By (11)

PHPUnit DOM Assertions
======================

[](#phpunit-dom-assertions)

[![Latest Stable Version](https://camo.githubusercontent.com/49ef57fa9d863f7f59c9cec1ed72f89c2ea14db6c08f8b67480c235c36b22814/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870756e69742f706870756e69742d646f6d2d617373657274696f6e732e737667)](https://packagist.org/packages/phpunit/phpunit-dom-assertions)[![Downloads](https://camo.githubusercontent.com/168369eeabaad17604ede4bf7bef03072be0e08bffbc7f55dbfdb37115ae852b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870756e69742f706870756e69742d646f6d2d617373657274696f6e732e737667)](https://packagist.org/packages/phpunit/phpunit-dom-assertions)[![Integrate](https://github.com/lstrojny/phpunit-dom-assertions/workflows/CI/badge.svg?branch=master)](https://github.com/lstrojny/phpunit-dom-assertions/actions)

A work in progress, drop-in replacement for the following deprecated PHPUnit assertions:

- `assertSelectCount()`
- `assertSelectRegExp()`
- `assertXPathCount()`
- `assertXPathEquals()`
- `assertXPathSelectRegExp()`
- `assertSelectEquals()`

Installation
------------

[](#installation)

```
$ composer require --dev phpunit/phpunit-dom-assertions
```

Usage
-----

[](#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
-------

[](#license)

The PHPUnit DOM assertions library is licensed under the [BSD 3-Clause license](LICENSE).

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity48

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~198 days

Recently: every ~90 days

Total

18

Last Release

95d ago

Major Versions

v0.1.0 → v2.0.02017-02-06

v2.6.0 → v3.0.02023-03-15

PHP version history (8 changes)v0.1.0PHP &gt;=5.3.3

v2.0.0PHP &gt;=7.0.0

v2.0.1PHP ~7

v2.3.0PHP &gt;=7.1

v3.0.0PHP ~8.1.0 || ~8.2.0

v3.1.0PHP ~8.2.0 || ~8.3.0

v3.3.0PHP ~8.3.0 || ~8.4.0

v3.6.0PHP ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/79707?v=4)[Lars Strojny](/maintainers/lstrojny)[@lstrojny](https://github.com/lstrojny)

---

Top Contributors

[![lstrojny](https://avatars.githubusercontent.com/u/79707?v=4)](https://github.com/lstrojny "lstrojny (21 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (18 commits)")[![whatthejeff](https://avatars.githubusercontent.com/u/306525?v=4)](https://github.com/whatthejeff "whatthejeff (7 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![borro](https://avatars.githubusercontent.com/u/1752024?v=4)](https://github.com/borro "borro (2 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (1 commits)")[![henriquemoody](https://avatars.githubusercontent.com/u/154023?v=4)](https://github.com/henriquemoody "henriquemoody (1 commits)")[![phanan](https://avatars.githubusercontent.com/u/8056274?v=4)](https://github.com/phanan "phanan (1 commits)")[![dawehner](https://avatars.githubusercontent.com/u/29678?v=4)](https://github.com/dawehner "dawehner (1 commits)")[![vnccrl78](https://avatars.githubusercontent.com/u/71378271?v=4)](https://github.com/vnccrl78 "vnccrl78 (1 commits)")[![charliemcr](https://avatars.githubusercontent.com/u/7997974?v=4)](https://github.com/charliemcr "charliemcr (1 commits)")

---

Tags

phpunitcssdomassertionstestsXpath

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpunit-phpunit-dom-assertions/health.svg)

```
[![Health](https://phpackages.com/badges/phpunit-phpunit-dom-assertions/health.svg)](https://phpackages.com/packages/phpunit-phpunit-dom-assertions)
```

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2021.0M277](/packages/drupal-core-dev)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[juampi92/test-seo

Easy way to test your SEO

26341.0k](/packages/juampi92-test-seo)[aik099/phpunit-mink

Library for using Mink in PHPUnit tests. Supports session sharing between tests in a test case.

72136.2k1](/packages/aik099-phpunit-mink)[stevegrunwell/phpunit-markup-assertions

Assertions for PHPUnit to verify the presence or state of elements within markup

16150.1k5](/packages/stevegrunwell-phpunit-markup-assertions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
