\ChadicusArrayAssertsTrait

Trait for adding asserts for arrays

Summary

Methods
Properties
Constants
assertSameArray()
assertCount()
assertInternalType()
assertSame()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

assertSameArray()

assertSameArray(array  $expected, mixed  $actual, string|null  $prefix = null) : void

Asserts the given $actual array is the same as the $expected array disregarding index order

Parameters

array $expected

The expected array.

mixed $actual

The actual array.

string|null $prefix

Prefix to use with error messages. Useful for nested arrays.

assertCount()

assertCount(integer  $expectedCount, mixed  $haystack, string  $message = '') : void

Asserts the number of elements of an array, Countable or Traversable.

Ensures this method must be provided by classes using this trait.

Parameters

integer $expectedCount

The expected number of items in $haystack.

mixed $haystack

The array, countable or traversable object containing items.

string $message

Optional error message to give upon failure.

assertInternalType()

assertInternalType(string  $expected, mixed  $actual, string  $message = '') : void

Asserts that a variable is of a given type.

Ensures this method must be provided by classes using this trait.

Parameters

string $expected

The expected internal type.

mixed $actual

The variable to verify.

string $message

Optional error message to give upon failure.

assertSame()

assertSame(string  $expected, mixed  $actual, string  $message = '') : void

Asserts that two variables have the same type and value. Used on objects, it asserts that two variables reference the same object.

Ensures this method must be provided by classes using this trait.

Parameters

string $expected

The expected value.

mixed $actual

The actual value.

string $message

Optional error message to give upon failure.