A work in progress, drop-in replacement for the following deprecated PHPUnit assertions:
assertSelectCount()
assertSelectRegExp()
assertSelectEquals()
assertTag()
(not yet ported)assertNotTag()
(not yet ported)
- Port
assertTag()
andassertNotTag()
. - Improve tests.
- Improve error messages.
- Improve comments and documentation.
- Add XPath support.
The PHPUnit DOM assertions require PHP 7.0 or later.
The recommended way to install the PHPUnit DOM assertions is
through composer. Just create a composer.json
file
and run the php composer.phar install
command to install it:
{
"require-dev": {
"phpunit/phpunit-dom-assertions": "~2"
}
}
Extend PHPUnit\Framework\DOMTestCase
to use the DOM assertions:
namespace My\Tests;
use PHPUnit\Framework\DOMTestCase;
class DOMTest extends DOMTestCase
{
public function testSelectEquals()
{
$html = file_get_contents('test.html');
$selector = 'span.test_class';
$content = 'Test Class Text';
$this->assertSelectEquals($selector, $content, true, $html);
}
}
To run the test suite, you need composer.
$ php composer.phar install
$ vendor/bin/phpunit
The PHPUnit DOM assertions library is licensed under the BSD 3-Clause license.