wmde/hamcrest-html-matchers

Name: hamcrest-html-matchers

Owner: Wikimedia Deutschland e.V.

Description: Set of Hamcrest matchers for HTML assertrions

Created: 2017-01-24 12:00:03.0

Updated: 2018-04-19 10:30:13.0

Pushed: 2018-05-14 08:46:23.0

Homepage: null

Size: 94

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This is the set of Hamcrest matchers for HTML assertions

Build Status Scrutinizer Code Quality Code Coverage

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:

l = '<div>
        <form>
            <input name="password" value="strong password"/>
        </form>
     </div>';

rtThat($html, is(htmlPiece(
havingChild(
    both(withTagName('form'))
    ->andAlso(
        havingDirectChild(
            allOf(
                withTagName('input'),
                withAttribute('name')->havingValue('password'),
                withAttribute('value')->havingValue(not('weak password')))))))));

Usage limitations:

Documentation

Information about general Hamcrest usage can be found at Hamcrest GitHub repository.

Available Matchers

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.