Download the PHP package stevegrunwell/phpunit-markup-assertions without Composer

On this page you can find all versions of the php package stevegrunwell/phpunit-markup-assertions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpunit-markup-assertions

PHPUnit Markup Assertions

Build Status Code Coverage GitHub Release

This library introduces the MarkupAssertionsTrait trait for use in PHPUnit tests.

These assertions enable you to inspect generated markup without having to muddy tests with DOMDocument or nasty regular expressions. If you're generating markup at all with PHP, the PHPUnit Markup Assertions trait aims to make the output testable without making your tests fragile.

Example

Installation

To add PHPUnit Markup Assertions to your project, first install the library via Composer:

Next, import the SteveGrunwell\PHPUnit_Markup_Assertions\MarkupAssertionsTrait trait into each test case that will leverage the assertions:

Making PHPUnit Markup Assertions available globally

If you'd like the methods to be available across your entire test suite, you might consider sub-classing the PHPUnit test case and applying the trait there:

Then update your other test cases to use your new base:

Available methods

These are the assertions made available to PHPUnit via the MarkupAssertionsTrait.

assertContainsSelector()

Assert that the given string contains an element matching the given selector.

(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should contain the $selector.
(string) $message
A message to display if the assertion fails.

Example

assertNotContainsSelector()

Assert that the given string does not contain an element matching the given selector.

This method is the inverse of assertContainsSelector().

(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should not contain the $selector.
(string) $message
A message to display if the assertion fails.

assertSelectorCount()

Assert the number of times an element matching the given selector is found.

(int) $count
The number of matching elements expected.
(string) $selector
A query selector for the element to find.
(string) $markup
The markup to run the assertion against.
(string) $message
A message to display if the assertion fails.

Example

assertHasElementWithAttributes()

Assert that an element with the given attributes exists in the given markup.

(array) $attributes
An array of HTML attributes that should be found on the element.
(string) $markup
The markup that should contain an element with the provided $attributes.
(string) $message
A message to display if the assertion fails.

Example

assertNotHasElementWithAttributes()

Assert that an element with the given attributes does not exist in the given markup.

(array) $attributes
An array of HTML attributes that should not be found on the element.
(string) $markup
The markup that should not contain an element with the provided $attributes.
(string) $message
A message to display if the assertion fails.

assertElementContains()

Assert that the element with the given selector contains a string.

(string) $contents
The string to look for within the DOM node's contents.
(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should contain the $selector.
(string) $message
A message to display if the assertion fails.

Example

assertElementNotContains()

Assert that the element with the given selector does not contain a string.

This method is the inverse of assertElementContains().

(string) $contents
The string to look for within the DOM node's contents.
(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should contain the $selector.
(string) $message
A message to display if the assertion fails.

assertElementRegExp()

Assert that the element with the given selector contains a string.

This method works just like assertElementContains(), but uses regular expressions instead of simple string matching.

(string) $regexp
The regular expression pattern to look for within the DOM node.
(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should contain the $selector.
(string) $message
A message to display if the assertion fails.

assertElementNotRegExp()

Assert that the element with the given selector does not contain a string.

This method is the inverse of assertElementNotContains() except with regular expressions instead of simple string matching.

(string) $regexp
The regular expression pattern to look for within the DOM node.
(string) $selector
A query selector for the element to find.
(string) $markup
The markup that should contain the $selector.
(string) $message
A message to display if the assertion fails.

All versions of phpunit-markup-assertions with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0 || ^8.0
laminas/laminas-dom Version ~2.7.2 || ^2.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stevegrunwell/phpunit-markup-assertions contains the following files

Loading the files please wait ....