use BootPress\HTMLUnit\Component as HTMLUnit;
![License MIT][badge-license]
![PHP 7 Supported][badge-php]
![Code Climate][badge-code-climate]
, (*1)
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., (*2)
Installation
Add the following to your composer.json
file., (*3)
``` bash
{
"require-dev": {
"bootpress/htmlunit": "^1.0"
}
}, (*4)
## Example Usage
``` php
<?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>',
'
Content, (*5)
',
'</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: /^...$/
., (*6)
License
The MIT License (MIT). Please see License File for more information., (*7)