HumHub Documentation (unofficial)

Comparator extends Comparator
in package

FinalYes

Use this Comparator to get nice output when using PHPUnit assertEquals() with Enums.

Add this to your PHPUnit bootstrap PHP file:

\SebastianBergmann\Comparator\Factory::getInstance()->register(new \MyCLabs\Enum\PHPUnit\Comparator());

Table of Contents

Properties

$exporter  : Exporter
$factory  : Factory

Methods

__construct()  : mixed
accepts()  : bool
Returns whether the comparator can compare two values.
assertEquals()  : void
Asserts that two values are equal.
setFactory()  : mixed
formatEnum()  : mixed

Properties

Methods

accepts()

Returns whether the comparator can compare two values.

public accepts(mixed $expected, mixed $actual) : bool
Parameters
$expected : mixed

The first value to compare

$actual : mixed

The second value to compare

Return values
bool

assertEquals()

Asserts that two values are equal.

public assertEquals(Enum $expected, Enum|null $actual[, mixed $delta = 0.0 ][, mixed $canonicalize = false ][, mixed $ignoreCase = false ]) : void
Parameters
$expected : Enum
$actual : Enum|null
$delta : mixed = 0.0

Allowed numerical distance between two values to consider them equal

$canonicalize : mixed = false

Arrays are sorted before comparison when set to true

$ignoreCase : mixed = false

Case is ignored when set to true

formatEnum()

private formatEnum([Enum $enum = null ]) : mixed
Parameters
$enum : Enum = null

        
On this page

Search results