bootpress/htmlunit
Composer 安装命令:
composer require bootpress/htmlunit
包简介
Enables you to thoroughly test the HTML output of your code.
README 文档
README
Extends PHPUnit and combines the assertEquals and assertRegExp assertions into one assertEqualsRegExp method that enables you to thoroughly test the HTML output of your code.
Installation
Add the following to your composer.json file.
{
"require-dev": {
"bootpress/htmlunit": "^1.0"
}
}
Example Usage
<?php class MyTest extends \BootPress\HTMLUnit\Component { public function testOutput() { $html = <<<'EOT' <!doctype html> <html lang="en-us"> <head><meta charset="UTF-8"> <title>Title</title></head> <body> <p>Content</p> </body> </html> EOT; $this->assertEqualsRegExp(array( '<!doctype {{ [^>]+ }}>', '<html lang="{{ [a-z-]+ }}">', '<head>', '<meta charset="{{ [A-Z0-9-]+ }}">', '<title>Title</title>', '</head>', '<body>', '<p>Content</p>', '</body>', '</html>', ), $html); } }
Notice that all of the whitespace surrounding the array values are ignored. Regular expressions are enclosed Twig style {{ ... }} with two curly braces and a space on both ends. Internally the regex is wrapped like so: /^...$/.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1.52k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-01