Skip to content

A work in progress, drop-in replacement for PHPUnit's deprecated DOM assertions.

License

Notifications You must be signed in to change notification settings

watcher46/phpunit-dom-assertions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHPUnit DOM Assertions

A work in progress, drop-in replacement for the following deprecated PHPUnit assertions:

  • assertSelectCount()
  • assertSelectRegExp()
  • assertSelectEquals()
  • assertTag() (not yet ported)
  • assertNotTag() (not yet ported)

TODO

  • Port assertTag() and assertNotTag().
  • Improve tests.
  • Improve error messages.
  • Improve comments and documentation.
  • Add XPath support.

Requirements

The PHPUnit DOM assertions require PHP 7.0 or later.

Installation

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"
    }
}

Usage

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);
    }
}

Tests

Build Status

To run the test suite, you need composer.

$ php composer.phar install
$ vendor/bin/phpunit

License

The PHPUnit DOM assertions library is licensed under the BSD 3-Clause license.

About

A work in progress, drop-in replacement for PHPUnit's deprecated DOM assertions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 96.8%
  • HTML 3.2%