trait ViewResultAssertionTrait (View source)

Provides a class for assertions to check for the expected result of a View.

Methods

bool
assertIdenticalResultset(ViewExecutable $view, array $expected_result, array $column_map = [], string $message = NULL)

Verifies that a result set returned by a View matches expected values.

bool
assertNotIdenticalResultset(ViewExecutable $view, array $expected_result, array $column_map = [], string $message = NULL)

Verifies that a result set returned by a View differs from certain values.

bool
assertIdenticalResultsetHelper(ViewExecutable $view, array $expected_result, array $column_map, string $assert_method, string $message = NULL)

Performs View result assertions.

Details

protected bool assertIdenticalResultset(ViewExecutable $view, array $expected_result, array $column_map = [], string $message = NULL)

Verifies that a result set returned by a View matches expected values.

The comparison is done on the string representation of the columns of the column map, taking the order of the rows into account, but not the order of the columns.

Parameters

ViewExecutable $view

An executed View.

array $expected_result

An expected result set.

array $column_map

(optional) An associative array mapping the columns of the result set from the view (as keys) and the expected result set (as values).

string $message

(optional) A custom message to display with the assertion. Defaults to 'Identical result set.'

Return Value

bool

TRUE if the assertion succeeded, or FALSE otherwise.

protected bool assertNotIdenticalResultset(ViewExecutable $view, array $expected_result, array $column_map = [], string $message = NULL)

Verifies that a result set returned by a View differs from certain values.

Inverse of ViewsTestCase::assertIdenticalResultset().

Parameters

ViewExecutable $view

An executed View.

array $expected_result

An expected result set.

array $column_map

(optional) An associative array mapping the columns of the result set from the view (as keys) and the expected result set (as values).

string $message

(optional) A custom message to display with the assertion. Defaults to 'Non-identical result set.'

Return Value

bool

TRUE if the assertion succeeded, or FALSE otherwise.

protected bool assertIdenticalResultsetHelper(ViewExecutable $view, array $expected_result, array $column_map, string $assert_method, string $message = NULL)

Performs View result assertions.

This is a helper method for ViewTestBase::assertIdenticalResultset() and ViewTestBase::assertNotIdenticalResultset().

Parameters

ViewExecutable $view

An executed View.

array $expected_result

An expected result set.

array $column_map

An associative array mapping the columns of the result set from the view (as keys) and the expected result set (as values).

string $assert_method

The TestBase assertion method to use (either 'assertIdentical' or 'assertNotIdentical').

string $message

(optional) The message to display with the assertion.

Return Value

bool

TRUE if the assertion succeeded, or FALSE otherwise.