GenericAssertionsTrait
Class ExtraAssertionsTrait
Table of Contents
Methods
- assertApproxEquals() : mixed
- Assert that two numbers are approximately equal, give or take some $tolerance.
- assertArrayKeyExists() : mixed
- assertArrayValueNotNull() : mixed
- assertArrayValuesEqual() : mixed
- Assert the 2 arrays have the same values.
- assertAttributesEquals() : mixed
- Assert attributes are equal.
- assertTreeEquals() : mixed
- Assert that two array-trees are exactly equal.
- assertType() : mixed
Methods
assertApproxEquals()
Assert that two numbers are approximately equal, give or take some $tolerance.
public
assertApproxEquals(int|float $expected, int|float $actual, int|float $tolerance[, string $message = NULL ]) : mixed
Parameters
- $expected : int|float
- $actual : int|float
- $tolerance : int|float
-
Any differences <$tolerance are considered irrelevant. Differences >=$tolerance are considered relevant.
- $message : string = NULL
assertArrayKeyExists()
public
assertArrayKeyExists(string|int $key, array<string|int, mixed> &$list) : mixed
Parameters
- $key : string|int
- $list : array<string|int, mixed>
assertArrayValueNotNull()
public
assertArrayValueNotNull(string|int $key, array<string|int, mixed> &$list) : mixed
Parameters
- $key : string|int
- $list : array<string|int, mixed>
assertArrayValuesEqual()
Assert the 2 arrays have the same values.
public
assertArrayValuesEqual(array<string|int, mixed> $array1, array<string|int, mixed> $array2) : mixed
The order of arrays, and keys of the arrays, do not affect the outcome.
Parameters
- $array1 : array<string|int, mixed>
- $array2 : array<string|int, mixed>
assertAttributesEquals()
Assert attributes are equal.
public
assertAttributesEquals(array<string|int, mixed> $expectedValues, array<string|int, mixed> $actualValues[, string $message = NULL ]) : mixed
Parameters
- $expectedValues : array<string|int, mixed>
- $actualValues : array<string|int, mixed>
- $message : string = NULL
Tags
assertTreeEquals()
Assert that two array-trees are exactly equal.
public
assertTreeEquals(array<string|int, mixed> $expected, array<string|int, mixed> $actual) : mixed
The ordering of keys do not affect the outcome (within either the roots or in any child elements).
Error messages will reveal a readable -path-, regardless of how many levels of nesting are present.
Parameters
- $expected : array<string|int, mixed>
- $actual : array<string|int, mixed>
assertType()
public
assertType(string $expected, mixed $actual[, string $message = '' ]) : mixed
Parameters
- $expected : string
-
Ex: 'array', 'object', 'int'
- $actual : mixed
-
The variable/item to check.
- $message : string = ''