PHPackages                             spiderling-php/phpunit-matches-selector - 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. spiderling-php/phpunit-matches-selector

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

spiderling-php/phpunit-matches-selector
=======================================

PHPUnit extension for asserting if a dom element matches a given css selector

0.2.0(10y ago)1162BSD-3-ClausePHP

Since Sep 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/spiderling-php/phpunit-matches-selector)[ Packagist](https://packagist.org/packages/spiderling-php/phpunit-matches-selector)[ RSS](/packages/spiderling-php-phpunit-matches-selector/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Phpunit Matches Selector
========================

[](#phpunit-matches-selector)

[![Build Status](https://camo.githubusercontent.com/e5c89039588b7d75ecc35dee4d2dba5c1ed59ffa4ecb2e62fe88aaa19b1c69b6/68747470733a2f2f7472617669732d63692e6f72672f7370696465726c696e672d7068702f706870756e69742d6d6174636865732d73656c6563746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/spiderling-php/phpunit-matches-selector)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a286ce0554404cd60c8a3ef8a07f79d9faaa561608d5892955bcb7fc2b2d7cb7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696465726c696e672d7068702f706870756e69742d6d6174636865732d73656c6563746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spiderling-php/phpunit-matches-selector/)[![Code Coverage](https://camo.githubusercontent.com/fa1fbcf18806ed6593b4fd96c25c558e629d839fd10a3900a5785f2ddac267e0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696465726c696e672d7068702f706870756e69742d6d6174636865732d73656c6563746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spiderling-php/phpunit-matches-selector/)[![Latest Stable Version](https://camo.githubusercontent.com/e2b02f74d1deace8745cf250b4f11d75e174878348bc4700a36577b802e7793f/68747470733a2f2f706f7365722e707567782e6f72672f7370696465726c696e672d7068702f706870756e69742d6d6174636865732d73656c6563746f722f762f737461626c652e706e67)](https://packagist.org/packages/spiderling-php/phpunit-matches-selector)

PHPUnit extension for asserting if a dom element matches a given css selector

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

[](#installation)

Install via composer

```
composer require --dev spiderling-php/phpunit-matches-selector

```

Since it is meant as an extension for your tests, all the requirements are in require-dev. PHPUnit requirement is not explicitly stated as its assumed you will need it anyway to use in your tests.

Usage
-----

[](#usage)

This extension allows to check if a DOMElement matches a particular css selector

```
use SP\PhpunitDomConstraints\DomConstraintsTrait;
use PHPUnit_Framework_TestCase;

class TestCaseTest extends PHPUnit_Framework_TestCase
{
    use DomConstraintsTrait;

    public function testTest()
    {
        $document = new DOMDocument();
        $document->load('Some file');

        $element = $document->getElementById('some id');

        // Here is the test you can now perform
        $this->assertMatchesSelector('div.some-class', $element, 'This should match');

        // You can do even more complex selects
        $this->assertMatchesSelector('ul li > #test.some-class[disabled]', $element, 'This should match');
    }
}
```

License
-------

[](#license)

Copyright (c) 2015, Clippings Ltd. Developed by Ivan Kerin

Under BSD-3-Clause license, read LICENSE file.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

2

Last Release

3941d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/506129?v=4)[Harry Dobrev](/maintainers/hkdobrev)[@hkdobrev](https://github.com/hkdobrev)

---

Top Contributors

[![ivank](https://avatars.githubusercontent.com/u/4976?v=4)](https://github.com/ivank "ivank (8 commits)")

### Embed Badge

![Health badge](/badges/spiderling-php-phpunit-matches-selector/health.svg)

```
[![Health](https://phpackages.com/badges/spiderling-php-phpunit-matches-selector/health.svg)](https://phpackages.com/packages/spiderling-php-phpunit-matches-selector)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M361](/packages/dms-phpunit-arraysubset-asserts)[gong023/assert_chain

enable you to use phpunit assert with method chain

1478.9k3](/packages/gong023-assert-chain)

PHPackages © 2026

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