Download the PHP package jroszkiewicz/phpunit-xpath-assertions without Composer
On this page you can find all versions of the php package jroszkiewicz/phpunit-xpath-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jroszkiewicz/phpunit-xpath-assertions
More information about jroszkiewicz/phpunit-xpath-assertions
Files in jroszkiewicz/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
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.
All versions of phpunit-xpath-assertions with dependencies
ext-dom Version *
ext-json Version *
phpunit/phpunit Version ^8.0 || ^9.0 || ^10.0