# hamcrest/hamcrest-php

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/hamcrest-hamcrest-php).**

7,007 stars · 46 forks · PHP · NOASSERTION

## Links

- GitHub: https://github.com/hamcrest/hamcrest-php
- awesome-repositories: https://awesome-repositories.com/repository/hamcrest-hamcrest-php.md

## Description

Hamcrest PHP is a declarative assertion framework and matcher library used for unit testing in PHP. It provides a set of flexible matchers to verify object states, data types, and collection contents.

The library includes specialized tools for XML verification using XPath expressions to analyze document structures and element content. It also allows for the creation of complex validation rules by combining multiple independent matchers through logical operators.

The framework covers a broad range of validation primitives, including string content inspection, numeric comparison, and object property verification. It also provides utilities for checking data types and validating the size and contents of arrays and traversable collections.

## Tags

### Testing & Quality Assurance

- [PHP Data Assertion Tools](https://awesome-repositories.com/f/testing-quality-assurance/php-data-assertion-tools.md) — Provides a comprehensive set of assertion tools for verifying PHP values and nested object contents.
- [Collection Size Assertions](https://awesome-repositories.com/f/testing-quality-assurance/collection-size-assertions.md) — Checks if traversable collections are empty or contain a specific number of elements. ([source](https://github.com/hamcrest/hamcrest-php#readme))
- [Numeric Assertions](https://awesome-repositories.com/f/testing-quality-assurance/numeric-assertions.md) — Evaluates numeric values based on equality, range proximity, and relative magnitude. ([source](https://github.com/hamcrest/hamcrest-php#readme))
- [PHP Value Comparison Libraries](https://awesome-repositories.com/f/testing-quality-assurance/php-value-comparison-libraries.md) — Provides a flexible library of matchers to check equality and specific criteria between complex PHP data types.
- [Collection Content Validations](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/assertions-and-validation/assertion-validation-utilities/assertion-libraries/collection-membership-assertions/collection-content-validations.md) — Implements comprehensive checks for element presence, count, and ordering within PHP arrays and collections.
- [Unit Testing Utilities](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/test-levels-and-types/unit-testing-utilities.md) — Implements a declarative API for validating object states, data types, and collection contents during unit testing.
- [String Assertions](https://awesome-repositories.com/f/testing-quality-assurance/string-assertions.md) — Implements specialized matchers for analyzing string content, substrings, and patterns. ([source](https://github.com/hamcrest/hamcrest-php#readme))
- [Type Assertions](https://awesome-repositories.com/f/testing-quality-assurance/type-assertions.md) — Includes utilities to verify that values match specific scalar or compound data types. ([source](https://github.com/hamcrest/hamcrest-php#readme))
- [Unit Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/unit-testing-frameworks.md) — Provides a library for defining and executing automated assertions to verify code logic and correctness.
- [Assertion Matchers](https://awesome-repositories.com/f/testing-quality-assurance/assertion-matchers.md) — Provides a system for grouping multiple matchers using logical operators to create complex validation rules. ([source](https://github.com/hamcrest/hamcrest-php#readme))

### Software Engineering & Architecture

- [Object and Collection Assertions](https://awesome-repositories.com/f/software-engineering-architecture/data-schema-validation/data-type-validation/object-shape-validation/recursive-object-validation/object-and-collection-assertions.md) — Checks class inheritance, object properties, and the contents of traversable collections or arrays.
- [Object Member Assertions](https://awesome-repositories.com/f/software-engineering-architecture/object-property-inspectors/property-extraction-validation/object-member-assertions.md) — Compares object instances by identity or value and verifies class inheritance. ([source](https://github.com/hamcrest/hamcrest-php#readme))
- [Assertion Logic Combinators](https://awesome-repositories.com/f/software-engineering-architecture/boolean-logic-combinators/assertion-logic-combinators.md) — Provides capabilities to combine multiple independent matchers using logical AND and OR operations for complex validation.

### Web Development

- [String Pattern Validators](https://awesome-repositories.com/f/web-development/string-pattern-validators.md) — Provides utilities for verifying PHP strings against regular expression patterns, substrings, and equality.
- [XPath Assertions](https://awesome-repositories.com/f/web-development/schema-validation/xml-schema-validations/xpath-assertions.md) — Provides specialized matchers to analyze and verify XML document structures using XPath expressions. ([source](https://github.com/hamcrest/hamcrest-php#readme))

### Part of an Awesome List

- [XML XPath Matchers](https://awesome-repositories.com/f/awesome-lists/devtools/html-and-xml-processing/xpath-data-extractors/xml-xpath-matchers.md) — Provides specialized tools for XML verification using XPath expressions to analyze document structures.

### Data & Databases

- [Composite Assertion Matchers](https://awesome-repositories.com/f/data-databases/structural-data-validators/nested-data-matchers/composite-assertion-matchers.md) — Implements complex validation rules by nesting simple matcher objects within logical operator objects.

### Programming Languages & Runtimes

- [XML Verification Matchers](https://awesome-repositories.com/f/programming-languages-runtimes/string-parsing/xml-and-html-document-parsers/xml-verification-matchers.md) — Uses XPath expressions to analyze and verify the structure and content of XML documents in PHP applications.
