Search by

packagefactory / phpunit-custom-assertions

wilhelm.behnckeNezanielmficzelmhsdesign

Custom PHPUnit assertions for use in PackageFactory packages

Package info

codeberg.org/PackageFactory/phpunit-custom-assertions

Issues

pkg:composer/packagefactory/phpunit-custom-assertions

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

v0.1.1 2026-10-02 14:08 UTC

This package is auto-updated.

Last update: 2026-10-02 12:09:05 UTC


README

Custom PHPUnit assertions for use in PackageFactory packages

Installation

You can install this package using composer:

composer require --dev packagefactory/phpunit-custom-assertions

Usage

To use the custom assertions, just include the CustomAssetions trait with your PHPUnit test case:

declare(strict_types=1);

use PackageFactory\PhpUnit\CustomAssertions\CustomAssertions;
use PHPUnit\Framework\TestCase;

final class MyTest extends TestCase
{
    use CustomAssertions;

    // ...
}

Available Custom Assertions

assertDeepEquals

function assertDeepEquals(
    mixed $expected,
    mixed $actual,
    array $customComparisonFns = [],
    string $message = ''
): void

This assertion compares two values recursively. By default, objects are compared property-by-property and arrays are compared item-by-item.

For objects, you can provide custom comparison functions per-class via the $customComparisonFns parameter.

EXAMPLE:

self::assertDeepEquals(
    ['foo' => ['bar' => 'baz']],
    ['foo' => ['bar' => 'qux']],
);

OUTPUT:

Failed asserting that [...] deeply equals [...].

diff at path $value['foo']['bar']:
@@ -1 +1 @@
-'baz'
+'qux'

License

AGPLv3 logo that states "AGPLv3 - Free Software - Free as in Freedom"

see LICENSE