Download the PHP package thomasweinert/phpunit-xpath-assertions without Composer
On this page you can find all versions of the php package thomasweinert/phpunit-xpath-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thomasweinert/phpunit-xpath-assertions
More information about thomasweinert/phpunit-xpath-assertions
Files in thomasweinert/phpunit-xpath-assertions
Package phpunit-xpath-assertions
Short Description Xpath assertions and constraints for PHPUnit
License BSD-3-Clause
Informations about the package phpunit-xpath-assertions
phpunit-xpath-assertions
Xpath assertions and constraints for use with PHPUnit.
Example
Installation
Phar
If you're using PHPUnit as a PHAR, you can download this extension as PHAR, too. They the are available on the
release page. Download the extension *.phar
file
into a directory and provide the directory in the PHPUnit configuration file.
Composer
If you use Composer to manage the dependencies of your project then you can add the PHPUnit example extension as a development-time dependency to your project:
Usage
The library provides traits that you can use to add the assertions to your TestCase.
Constraints
Use trait PHPUnit\Xpath\Constraint
. They can be used with assertThat()
or
with Mocks.
self::matchesXpathExpression()
Validate if the provided Xpath expression matches something that is TRUE and not empty. It will fail if the expression returns an empty node list or an empty string or FALSE.
self::matchesXpathResultCount()
Returns true if the provided Xpath expression matches exactly the expected count of nodes.
self::equalToXpathResult()
If the expressions return a node list it compares the serialized XML of the matched nodes with the provided XML string or DOM. If the expression return a scalar uses a constraint depending on the type.
Assertions
Use trait PHPUnit\Xpath\Assert
. These assertions are shortcuts for
assertThat()
.
- self::assertXpathMatch()
- self::assertXpathCount()
- self::assertXpathEquals()
Namespaces
All methods have an optional argument that allow to provide an namespace definition.
JSON (>= 1.2.0)
The assertions can be used with JsonSerializable objects/arrays. They will be converted into a DOM representation internally.
Contributing
Contributions are welcome, please use the issue tracker to report bug and feature ideas.
Build a modified phar
This project includes build scripts to create your own phar file.
To create a phar call ./build/build-phar
.
Build a signed phar
To create a signed phar copy the dist.build.properties
to build.properties
and
set the gpg.user
. After that call ./build/build-phar package
.
All versions of phpunit-xpath-assertions with dependencies
ext-dom Version *
ext-json Version *
phpunit/phpunit Version ^8.0 || ^9.0