2017 © Pedro Peláez
 

library phpunit-expect

BDD-style assertions for PHPUnit

image

jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  • Wednesday, May 17, 2017
  • by jpkleemans
  • Repository
  • 2 Watchers
  • 12 Stars
  • 575 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

PHPUnit Expect

BDD-style assertions for PHPUnit, (*1)

Usage

``` php $number = 10;, (*2)

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

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

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


## Install With Composer: ``` bash composer require jpkleemans/phpunit-expect --dev

Or if you've installed PHPUnit globally:, (*6)

bash composer global require jpkleemans/phpunit-expect, (*7)

Expectations

toBe

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

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., (*9)

toEqual

Expect that two variables are equal., (*10)

notToEqual

Expect that two variables are not equal., (*11)

toHaveKey

Expect that an array has a specified key., (*12)

notToHaveKey

Expect that an array does not have a specified key., (*13)

toHaveSubset

Expect that an array has a specified subset., (*14)

toContain

Expect that a haystack contains a needle., (*15)

notToContain

Expect that a haystack does not contain a needle., (*16)

toContainOnly

Expect that a haystack contains only values of a given type., (*17)

notToContainOnly

Expect that a haystack does not contain only values of a given type., (*18)

toContainOnlyInstancesOf

Expect that a haystack contains only instances of a given classname, (*19)

toHaveCount

Expect the number of elements of an array, Countable or Traversable., (*20)

notToHaveCount

Expect the number of elements of an array, Countable or Traversable., (*21)

toBeEmpty

Expect that a variable is empty., (*22)

notToBeEmpty

Expect that a variable is not empty., (*23)

toBeGreaterThan

Expect that a value is greater than another value., (*24)

toBeGreaterThanOrEqualTo

Expect that a value is greater than or equal to another value., (*25)

toBeLessThan

Expect that a value is smaller than another value., (*26)

toBeLessThanOrEqualTo

Expect that a value is smaller than or equal to another value., (*27)

toEqualFile

Expect that the contents of one file or a string is equal to the contents of another file., (*28)

notToEqualFile

Expect that the contents of one file or a string is not equal to the contents of another file., (*29)

toExist

Expect that a file exists., (*30)

notToExist

Expect that a file does not exist., (*31)

toBeTrue

Expect that a condition is true., (*32)

notToBeTrue

Expect that a condition is not true., (*33)

toBeFalse

Expect that a condition is false., (*34)

notToBeFalse

Expect that a condition is not false., (*35)

toBeNull

Expect that a variable is null., (*36)

notToBeNull

Expect that a variable is not null., (*37)

toBeFinite

Expect that a variable is finite., (*38)

toBeInfinite

Expect that a variable is infinite., (*39)

toBeNan

Expect that a variable is nan., (*40)

toHaveAttribute

Expect that a class or an object has a specified attribute., (*41)

notToHaveAttribute

Expect that a class or an object does not have a specified attribute., (*42)

toHaveStaticAttribute

Expect that a class has a specified static attribute., (*43)

notToHaveStaticAttribute

Expect that a class does not have a specified static attribute., (*44)

toBeInstanceOf

Expect that a variable is of a given type., (*45)

notToBeInstanceOf

Expect that a variable is not of a given type., (*46)

toBeOfType

Expect that a variable is of a given type., (*47)

notToBeOfType

Expect that a variable is not of a given type., (*48)

toMatchRegExp

Expect that a string matches a given regular expression., (*49)

notToMatchRegExp

Expect that a string does not match a given regular expression., (*50)

toHaveSameSizeAs

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

notToHaveSameSizeAs

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

toMatchFormat

Expect that a string matches a given format string., (*53)

notToMatchFormat

Expect that a string does not match a given format string., (*54)

toMatchFormatFile

Expect that a string matches a given format file., (*55)

notToMatchFormatFile

Expect that a string does not match a given format string., (*56)

toStartWith

Expect that a string starts with a given prefix., (*57)

notToStartWith

Expect that a string starts not with a given prefix., (*58)

toEndWith

Expect that a string ends with a given suffix., (*59)

notToEndWith

Expect that a string ends not with a given suffix., (*60)

toEqualXmlFile

Expect that two XML files or documents are equal., (*61)

notToEqualXmlFile

Expect that two XML files or documents are not equal., (*62)

toEqualXml

Expect that two XML documents are equal., (*63)

notToEqualXml

Expect that two XML documents are not equal., (*64)

toHaveSameXMLStructureAs

Expect that a hierarchy of DOMElements matches., (*65)

toBeJson

Expect that a string is a valid JSON string., (*66)

toEqualJson

Expect that two given JSON encoded objects or arrays are equal., (*67)

notToEqualJson

Expect that two given JSON encoded objects or arrays are not equal., (*68)

toEqualJsonFile

Expect that the generated JSON encoded object and the content of the given file or JSON string are equal., (*69)

notToEqualJsonFile

Expect that the generated JSON encoded object and the content of the given file or JSON string are not equal., (*70)

The Versions

17/05 2017

dev-master

9999999-dev https://github.com/jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jan-Paul Kleemans

18/02 2016

0.2.1

0.2.1.0 https://github.com/jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  Sources   Download

MIT

The Development Requires

by Jan-Paul Kleemans

08/02 2016

0.2.0

0.2.0.0 https://github.com/jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  Sources   Download

MIT

The Development Requires

by Jan-Paul Kleemans

06/02 2016

0.1.1

0.1.1.0 https://github.com/jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  Sources   Download

MIT

The Development Requires

by Jan-Paul Kleemans

06/02 2016

0.1.0

0.1.0.0 https://github.com/jpkleemans/phpunit-expect

BDD-style assertions for PHPUnit

  Sources   Download

MIT

The Development Requires

by Jan-Paul Kleemans