All Projects → jpkleemans → phpunit-expect

jpkleemans / phpunit-expect

Licence: MIT license
BDD-style assertions for PHPUnit

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to phpunit-expect

Codeception
Full-stack testing PHP framework
Stars: ✭ 4,401 (+29240%)
Mutual labels:  bdd, phpunit
Verify
BDD Assertions for PHPUnit and Codeception
Stars: ✭ 127 (+746.67%)
Mutual labels:  bdd, phpunit
chai-exclude
Exclude keys to compare from a deep equal operation with chai expect or assert.
Stars: ✭ 33 (+120%)
Mutual labels:  bdd, expect
phpunit-extensions
Extensions for PHPUnit for Humbug
Stars: ✭ 17 (+13.33%)
Mutual labels:  phpunit
test-tools
Improves PHPUnit testing productivity by adding a service container and self-initializing fakes
Stars: ✭ 25 (+66.67%)
Mutual labels:  phpunit
kheera-testrunner-android
BDD Framework for Android
Stars: ✭ 18 (+20%)
Mutual labels:  bdd
expectest
Crate provides matchers and matcher functions for unit testing.
Stars: ✭ 25 (+66.67%)
Mutual labels:  expect
dusker
Stand alone Laravel Dusk test suit, which do not require Laravel framework itself
Stars: ✭ 28 (+86.67%)
Mutual labels:  phpunit
wp-phpunit
WordPress core PHPUnit library. [READ ONLY] Versions for new WordPress releases are built daily.
Stars: ✭ 65 (+333.33%)
Mutual labels:  phpunit
bdd
JUnit 5 based BDD library to create and run stories and behaviors a.k.a BDD specification tests
Stars: ✭ 25 (+66.67%)
Mutual labels:  bdd
phpunit-travis-ci-coverage-example
phpUnit Testing on Travis-CI with Code Coverage on CodeCov
Stars: ✭ 30 (+100%)
Mutual labels:  phpunit
azure-policy-testing
This repository outlines an automated testing approach for Azure Policies. The approach is fundamentally based on behavior-driven development (BDD) to improve communication between developers, security experts and compliance officers.
Stars: ✭ 78 (+420%)
Mutual labels:  bdd
apple-mango
Python BDD Pattern
Stars: ✭ 18 (+20%)
Mutual labels:  bdd
php-test-generator
Generate test cases for existing PHP files
Stars: ✭ 47 (+213.33%)
Mutual labels:  phpunit
php-mime-detector
Detect a file's mime type using magic numbers.
Stars: ✭ 20 (+33.33%)
Mutual labels:  phpunit
noise-php
A starter-kit for your PHP project.
Stars: ✭ 52 (+246.67%)
Mutual labels:  phpunit
gavel-spec
Behavior specification for Gavel, validator of HTTP transactions
Stars: ✭ 105 (+600%)
Mutual labels:  bdd
phpunit-json-assertions
JSON assertions for PHPUnit (including JSON Schema)
Stars: ✭ 30 (+100%)
Mutual labels:  phpunit
strict-phpunit
Enables type-safe comparisons of objects in PHPUnit.
Stars: ✭ 18 (+20%)
Mutual labels:  phpunit
demo-webdriverio-cucumber
E2E Tests with WebdriverIO and Cucumber
Stars: ✭ 28 (+86.67%)
Mutual labels:  bdd

PHPUnit Expect

BDD-style assertions for PHPUnit

Usage

$number = 10;

// Simple expectation
expect($number)->toBe(10);

// Negative expectation
expect($number)->notToBeOfType('string');

// Chained expectations
expect($number)
    ->toBeOfType('int')
    ->toBeGreaterThan(5)
    ->toBeLessThan(20);

Install

With Composer:

composer require jpkleemans/phpunit-expect --dev

Or if you've installed PHPUnit globally:

composer global require jpkleemans/phpunit-expect

Expectations

toBe

Expect that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.

notToBe

Expect that two variables do not have the same type and value. Used on objects, it asserts that two variables do not reference the same object.

toEqual

Expect that two variables are equal.

notToEqual

Expect that two variables are not equal.

toHaveKey

Expect that an array has a specified key.

notToHaveKey

Expect that an array does not have a specified key.

toHaveSubset

Expect that an array has a specified subset.

toContain

Expect that a haystack contains a needle.

notToContain

Expect that a haystack does not contain a needle.

toContainOnly

Expect that a haystack contains only values of a given type.

notToContainOnly

Expect that a haystack does not contain only values of a given type.

toContainOnlyInstancesOf

Expect that a haystack contains only instances of a given classname

toHaveCount

Expect the number of elements of an array, Countable or Traversable.

notToHaveCount

Expect the number of elements of an array, Countable or Traversable.

toBeEmpty

Expect that a variable is empty.

notToBeEmpty

Expect that a variable is not empty.

toBeGreaterThan

Expect that a value is greater than another value.

toBeGreaterThanOrEqualTo

Expect that a value is greater than or equal to another value.

toBeLessThan

Expect that a value is smaller than another value.

toBeLessThanOrEqualTo

Expect that a value is smaller than or equal to another value.

toEqualFile

Expect that the contents of one file or a string is equal to the contents of another file.

notToEqualFile

Expect that the contents of one file or a string is not equal to the contents of another file.

toExist

Expect that a file exists.

notToExist

Expect that a file does not exist.

toBeTrue

Expect that a condition is true.

notToBeTrue

Expect that a condition is not true.

toBeFalse

Expect that a condition is false.

notToBeFalse

Expect that a condition is not false.

toBeNull

Expect that a variable is null.

notToBeNull

Expect that a variable is not null.

toBeFinite

Expect that a variable is finite.

toBeInfinite

Expect that a variable is infinite.

toBeNan

Expect that a variable is nan.

toHaveAttribute

Expect that a class or an object has a specified attribute.

notToHaveAttribute

Expect that a class or an object does not have a specified attribute.

toHaveStaticAttribute

Expect that a class has a specified static attribute.

notToHaveStaticAttribute

Expect that a class does not have a specified static attribute.

toBeInstanceOf

Expect that a variable is of a given type.

notToBeInstanceOf

Expect that a variable is not of a given type.

toBeOfType

Expect that a variable is of a given type.

notToBeOfType

Expect that a variable is not of a given type.

toMatchRegExp

Expect that a string matches a given regular expression.

notToMatchRegExp

Expect that a string does not match a given regular expression.

toHaveSameSizeAs

Assert that the size of two arrays (or Countable or Traversable objects) is the same.

notToHaveSameSizeAs

Assert that the size of two arrays (or Countable or Traversable objects) is not the same.

toMatchFormat

Expect that a string matches a given format string.

notToMatchFormat

Expect that a string does not match a given format string.

toMatchFormatFile

Expect that a string matches a given format file.

notToMatchFormatFile

Expect that a string does not match a given format string.

toStartWith

Expect that a string starts with a given prefix.

notToStartWith

Expect that a string starts not with a given prefix.

toEndWith

Expect that a string ends with a given suffix.

notToEndWith

Expect that a string ends not with a given suffix.

toEqualXmlFile

Expect that two XML files or documents are equal.

notToEqualXmlFile

Expect that two XML files or documents are not equal.

toEqualXml

Expect that two XML documents are equal.

notToEqualXml

Expect that two XML documents are not equal.

toHaveSameXMLStructureAs

Expect that a hierarchy of DOMElements matches.

toBeJson

Expect that a string is a valid JSON string.

toEqualJson

Expect that two given JSON encoded objects or arrays are equal.

notToEqualJson

Expect that two given JSON encoded objects or arrays are not equal.

toEqualJsonFile

Expect that the generated JSON encoded object and the content of the given file or JSON string are equal.

notToEqualJsonFile

Expect that the generated JSON encoded object and the content of the given file or JSON string are not equal.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].