PHPackages                             phpfui/html-unit-tester - 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. phpfui/html-unit-tester

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

phpfui/html-unit-tester
=======================

PHPUnit Testing extensions for HMTL and CSS insures valid HTML and CSS via v.Nu validator

V1.0.14(1mo ago)54.7k12MITPHPPHP &gt;=8.0 &lt;8.6CI passing

Since Sep 7Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/phpfui/HTMLUnitTester)[ Packagist](https://packagist.org/packages/phpfui/html-unit-tester)[ Docs](https://github.com/phpfui/HTMLUnitTester)[ RSS](/packages/phpfui-html-unit-tester/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (16)Used By (2)

PHPFUI\\HTMLUnitTester [![Tests](https://github.com/phpfui/HTMLUnitTester/actions/workflows/tests.yml/badge.svg)](https://github.com/phpfui/HTMLUnitTester/actions?query=workflow%3Atests) [![Latest Packagist release](https://camo.githubusercontent.com/a34d810e515a26c5fdbc7a2fb6d759be9ba0faaa2d50ed114d9e6924a4aa33b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706675692f68746d6c2d756e69742d7465737465722e737667)](https://packagist.org/packages/phpfui/html-unit-tester) [![](https://camo.githubusercontent.com/742e8be8005b1fe76a64a5d8f5e6a5d4f63bf315e9a44a6d23e4e11c76b0555f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/742e8be8005b1fe76a64a5d8f5e6a5d4f63bf315e9a44a6d23e4e11c76b0555f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230362d627269676874677265656e2e7376673f7374796c653d666c6174)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#phpfuihtmlunittester---)

[PHPUnit](https://phpunit.de/) Testing extensions for HMTL and CSS. **PHPFUI\\HTMLUnitTester** allows you to unit test HTML and CSS for errors and warnings. Often simple errors in HTML or CSS create hard to debug issues where a simple check will reveal bad code.

This package will check detect errors and warnings in HTML and CSS in stand alone strings, files, entire directories or urls.

For the best performanance, a local install of  is recommended.

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

[](#installation)

```
composer require phpfui/html-unit-tester

```

Configuration
-------------

[](#configuration)

It is recommended you run  locally. Install [Java](https://www.java.com/ES/download/) and download the [.jar file](https://github.com/validator/validator/releases). Run with the following command:

```
java -Xss1024k -Dnu.validator.servlet.bind-address=127.0.0.1 -cp .\vnu.jar nu.validator.servlet.Main 8888

```

To run unit tests with GitHub Actions, add the following lines to you workflows test yml file:

```
- name: Setup Java
	uses: actions/setup-java@v5
	with:
		distribution: 'temurin'
		java-version: '11'

- name: Download vnu checker
	run: wget https://github.com/validator/validator/releases/download/latest/vnu.jar

- name: Run Nu Html Checker (v.Nu)
	run: java -cp vnu.jar -Xss2048k -Dnu.validator.servlet.bind-address=127.0.0.1 nu.validator.servlet.Main 8888 &

- name: Run Nu Html Checker (v.Nu)
	run: java -cp vnu.jar -Xss1024k -Dnu.validator.servlet.bind-address=127.0.0.1 nu.validator.servlet.Main 8888 &

```

Usage
-----

[](#usage)

Extend your unit tests from \\PHPFUI\\HTMLUnitTester\\Extensions

```
class UnitTest extends \PHPFUI\HTMLUnitTester\Extensions
  {
  public function testValidHtml()
    {
    $this->assertValidHtml('Header');
    $this->assertValidHtmlPage('TitleThis is a test');
    }
  }
```

You can use any of the following asserts:

- assertNotWarningCss
- assertNotWarningCssFile
- assertNotWarningCssUrl
- assertNotWarningFile
- assertNotWarningHtml
- assertNotWarningHtmlPage
- assertNotWarningUrl
- assertValidCss
- assertValidCssFile
- assertValidCssUrl
- assertValidFile
- assertValidHtml
- assertValidHtmlPage
- assertValidUrl

Directory Testing
-----------------

[](#directory-testing)

Instead of file by file testing, use **assertDirectory** to test an entire directory. Any files added to the directory will be automatically tested.

```
  $this->assertDirectory('ValidCSS', 'cssDirectory', 'Invalid CSS');
  $this->assertDirectory('NotWarningCSS', 'cssDirectory', 'CSS has warnings');
```

The error message will include the offending file name.

Examples
--------

[](#examples)

See [examples](https://github.com/phpfui/HTMLUnitTester/blob/master/tests/UnitTest.php)

Documentation
-------------

[](#documentation)

Full documentation at [PHPFUI\\HTMLUnitTester](http://phpfui.com/?p=d&n=PHPFUI%5CHTMLUnitTester)

License
-------

[](#license)

PHPFUI\\HTMLUnitTester is distributed under the MIT License.

### PHP Versions

[](#php-versions)

This library only supports **modern** versions of PHP which still receive security updates. While we would love to support PHP from the late Ming Dynasty, the advantages of modern PHP versions far out weigh quaint notions of backward compatibility. Time to upgrade.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

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

Recently: every ~267 days

Total

15

Last Release

59d ago

PHP version history (8 changes)V1.0.0PHP &gt;=7.1

V1.0.6PHP ^7.3 | &lt;8.1

V1.0.7PHP &gt;=7.4 &lt;8.2

V1.0.8PHP &gt;=7.4 &lt;8.3

V1.0.9PHP &gt;=8.0 &lt;8.3

V1.0.11PHP &gt;=8.0 &lt;8.4

V1.0.12PHP &gt;=8.0 &lt;8.5

V1.0.13PHP &gt;=8.0 &lt;8.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7434059?v=4)[Bruce Wells](/maintainers/PHPFUI)[@phpfui](https://github.com/phpfui)

---

Top Contributors

[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (55 commits)")

---

Tags

csshtmlphpunittestingphpunitunittestvalidationcsshtml

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpfui-html-unit-tester/health.svg)

```
[![Health](https://phpackages.com/badges/phpfui-html-unit-tester/health.svg)](https://phpackages.com/packages/phpfui-html-unit-tester)
```

###  Alternatives

[tcz/phpunit-mockfunction

PHPUnit extension that uses runkit to mock PHP functions (both user-defined and system)

4950.3k2](/packages/tcz-phpunit-mockfunction)[albertcht/lumen-testing

Testing Suite For Lumen like Laravel does.

4335.5k1](/packages/albertcht-lumen-testing)[sofa/eloquent-testsuite

Helpers for fast and reliable UNIT tests for your Eloquent Models with PHPUnit

10104.7k](/packages/sofa-eloquent-testsuite)

PHPackages © 2026

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