Download the PHP package wmde/hamcrest-html-matchers without Composer
On this page you can find all versions of the php package wmde/hamcrest-html-matchers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wmde/hamcrest-html-matchers
More information about wmde/hamcrest-html-matchers
Files in wmde/hamcrest-html-matchers
Package hamcrest-html-matchers
Short Description Set of Hamcrest matchers for HTML assertions
License LGPL-2.1
Informations about the package hamcrest-html-matchers
This is the set of Hamcrest matchers for HTML assertions
Usage examples
Hamcrest allows you to create pretty complicated and flexible assertions. Just remember:
"You can" does not mean "you should".
The following example shows how we can ensure that there is an HTML form and password entered in it is not weak:
Usage limitations:
- Each HTML assertion starts with
htmlPiece()call (is()can be used to improve readability) - One of
havingRootElement(),havingDirectChild()orhavingChild()needed to be passed as an argument tohtmlPiece()
Documentation
Information about general Hamcrest usage can be found at Hamcrest GitHub repository.
Available Matchers
-
htmlPiece()- checks that string is a valid HTML, parses it and passes control to given matcher if one present -
havingRootElement- checks given constraint against root element of HTML. NOTE: Can be passed only tohtmlPiece() -
havingDirectChild- checks given constraint against direct children -
havingChild- checks given constraint against all children -
withTagName- checks given constraint against tag name -
withAttribute- checks given constraint against elements attributes comparing names and values -
withClass- checks given constraint against element's class list -
havingTextContents- checks given constraint against elements text contents -
tagMatchingOutline- tolerantly checks that tag matches given outline (outline - tag representation in HTML format)That means:
- Element's tag name is equal to outline's tag name
- Element has all the attributes that outline has with the same values. If element has more attributes than outline it still matches.
- NOTE: Attribute
classis treated in a different manner (see further). - NOTE: If attribute outlined is boolean, then its value in element won't be checked, just presence.
- NOTE: Attribute
- Element has all html classes that outline has.
This will pass:
All versions of hamcrest-html-matchers with dependencies
ext-dom Version *
ext-libxml Version *
ext-mbstring Version *
hamcrest/hamcrest-php Version ^2.0.1

