Drupal Test Helpers module API documentation - release 1.3.1

AssertSequence
in package

Asserts that all values from a sequence were received in the right order.

Usage example:

$assertSequence = new AssertSequence(['Foo', 'Bar', 'Baz'], 'entityTitles');
TestHelpers::setMockedClassMethod(
  $controller,
  'buildListRow',
  function($entity) use ($assertSequence) {
    $assertSequence->assert($entity->title->value);
    return ['title' => $entity->title->value];
  }
);
$controller->articleList();
$assertSequence->finalize();

Table of Contents

Properties

$isExceptionThrown  : bool
A flag that an exception is thrown, to not exception again on __destruct.
$name  : string
A name of the assert object.
$nextItemDelta  : int
A pointer to the next expected element in the sequence.
$nextItemDeltaHuman  : int
A pointer to the next expected element in the sequence in human variable.
$values  : array<string|int, mixed>
A storage of the sequence values.

Methods

__construct()  : mixed
The constructor of the object.
__destruct()  : mixed
Calls the function finalize() to final check at the end of the execution.
assert()  : mixed
Asserts that the current value matches the expected sequence of values.
finalize()  : mixed
Finalizes the assertion with checking that all the expected items received.

Properties

$isExceptionThrown

A flag that an exception is thrown, to not exception again on __destruct.

private bool $isExceptionThrown = FALSE

$nextItemDelta

A pointer to the next expected element in the sequence.

private int $nextItemDelta

$nextItemDeltaHuman

A pointer to the next expected element in the sequence in human variable.

private int $nextItemDeltaHuman

$values

A storage of the sequence values.

private array<string|int, mixed> $values

Methods

__construct()

The constructor of the object.

public __construct(array<string|int, mixed> $values[, string|null $name = NULL ]) : mixed
Parameters
$values : array<string|int, mixed>

An ordered array of values to assert.

$name : string|null = NULL

A name for the object, to display in exceptions.

__destruct()

Calls the function finalize() to final check at the end of the execution.

public __destruct() : mixed

assert()

Asserts that the current value matches the expected sequence of values.

public assert(mixed $value) : mixed
Parameters
$value : mixed

finalize()

Finalizes the assertion with checking that all the expected items received.

public finalize() : mixed

        
On this page

Search results