https://github.com/kuria/phpunit-extras
Additional functionality for PHPUnit (such as assertions)
https://github.com/kuria/phpunit-extras
Last synced: about 1 month ago
JSON representation
Additional functionality for PHPUnit (such as assertions)
- Host: GitHub
- URL: https://github.com/kuria/phpunit-extras
- Owner: kuria
- License: mit
- Created: 2018-09-16T21:44:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-22T14:38:44.000Z (about 3 years ago)
- Last Synced: 2025-09-13T05:46:26.939Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
PHPUnit extras
##############
Additional functionality for PHPUnit (such as assertions).
.. image:: https://travis-ci.com/kuria/phpunit-extras.svg?branch=master
:target: https://travis-ci.com/kuria/phpunit-extras
.. contents::
Requirements
************
- PHP 7.1+
Usage
*****
``AssertionTrait``
==================
This trait exposes additional assertion methods to your test case.
.. code:: php
assertEqualIterable([1, 2, 3], new \ArrayObject([1, 2, 3]));
}
}
``assertLooselyIdentical($expected, $actual, $canonicalizeKeys = false)``
-------------------------------------------------------------------------
Assert that two values have the same type and value, but consider different
instances of the same class identical as long as they have identical properties.
If ``$canonicalizeKeys = TRUE``, then array key order is ignored.
``assertSameIterable(iterable $expected, $actual)``
---------------------------------------------------
Assert that two iterables contain the same values and types in the same order
Types are compared the same way as with the ``===`` operator.
``assertLooselyIdenticalIterable(iterable $expected, $actual, $canonicalizeKeys = false)``
------------------------------------------------------------------------------------------
Assert that two iterables contain the same values and types in the same order,
but consider different instances of the same class identical as long as they
have identical properties.
If ``$canonicalizeKeys = TRUE``, then array key order is ignored.
``assertEqualIterable(iterable $expected, $actual)``
----------------------------------------------------
Assert that two iterables contain equal values in any order
Types are compared the same way as with the ``==`` operator.
``looselyIdenticalTo($value, $canonicalizeKeys = false)``
---------------------------------------------------------
Create the ``IsLooselyIdentical`` constraint. See ``assertLooselyIdentical()``.
``identicalIterable(iterable $expected)``
-----------------------------------------
Create the ``IsIdenticalIterable`` constraint. See ``assertSameIterable()``.
``looselyIdenticalIterable(iterable $expected, $canonicalizeKeys = false)``
---------------------------------------------------------------------------
Create the ``IsLooselyIdenticalIterable`` constraint. See ``assertLooselyIdenticalIterable()``.
``equalIterable(iterable $expected)``
-------------------------------------
Create the ``IsEqualIterable`` constraint. See ``assertEqualIterable()``.
``ClockTrait``
==============
Mock current time in tests.
Only affects code that uses the `kuria/clock `_ component.
.. code:: php
atTime(1535904500, function () {
// some code that uses Kuria/Clock/Clock
});
}
}