phpfui/html-unit-tester
Composer 安装命令:
composer require --dev phpfui/html-unit-tester
包简介
PHPUnit Testing extensions for HMTL and CSS insures valid HTML and CSS via v.Nu validator
README 文档
README
PHPUnit 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 https://github.com/validator/validator is recommended.
Installation
composer require phpfui/html-unit-tester
Configuration
It is recommended you run https://github.com/validator/validator locally. Install Java 25 or higher and download the .jar file. 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: '25'
- 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 &
Usage
Extend your unit tests from \PHPFUI\HTMLUnitTester\Extensions
class UnitTest extends \PHPFUI\HTMLUnitTester\Extensions { public function testValidHtml() { $this->assertValidHtml('<h1>Header</h1>'); $this->assertValidHtmlPage('<!DOCTYPE html><html><head><meta charset="utf-8"/><title>Title</title></head><body><div>This is a test</div></body></html>'); } }
You can use any of the following asserts:
- assertNotWarningCss
- assertNotWarningCssFile
- assertNotWarningCssUrl
- assertNotWarningFile
- assertNotWarningHtml
- assertNotWarningHtmlPage
- assertNotWarningUrl
- assertValidCss
- assertValidCssFile
- assertValidCssUrl
- assertValidFile
- assertValidHtml
- assertValidHtmlPage
- assertValidUrl
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
See examples
Documentation
Full documentation at PHPFUI\HTMLUnitTester
License
PHPFUI\HTMLUnitTester is distributed under the MIT License.
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.
phpfui/html-unit-tester 适用场景与选型建议
phpfui/html-unit-tester 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.31k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 09 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「phpunit」 「css」 「test」 「validation」 「html」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phpfui/html-unit-tester 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phpfui/html-unit-tester 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phpfui/html-unit-tester 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for PHPUnit
A Twig extension to insert css as inline styles with a tag
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
Caching and compression for Twig assets (JavaScript and CSS).
The PHP SDK for Checkmango
统计信息
- 总下载量: 5.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 7
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-07