Documentation

DbTestTrait

Class DbTestTrait

Table of Contents

Methods

assertAttributesEquals()  : mixed
assertDBCompareValue()  : mixed
Compare a single column value in a retrieved DB record to an expected value.
assertDBCompareValues()  : mixed
Compare all values in a single retrieved DB record to an array of expected values.
assertDBNotNull()  : null|string
Request a record from the DB by seachColumn+searchValue. Success if a record is found.
assertDBNull()  : mixed
Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
assertDBQuery()  : void
Assert that a SQL query returns a given value.
assertDBRowExist()  : mixed
Request a record from the DB by id. Success if row not found.
assertDBRowNotExist()  : mixed
Request a record from the DB by id. Success if row not found.
assertDBState()  : void
Generic function to compare expected values after an api call to retrieved.

Methods

assertAttributesEquals()

public abstract assertAttributesEquals(mixed $expectedValues, mixed $actualValues[, mixed $message = NULL ]) : mixed
Parameters
$expectedValues : mixed
$actualValues : mixed
$message : mixed = NULL

assertDBCompareValue()

Compare a single column value in a retrieved DB record to an expected value.

public assertDBCompareValue(string $daoName, mixed $searchValue, mixed $returnColumn, mixed $searchColumn, mixed $expectedValue, mixed $message) : mixed
Parameters
$daoName : string
$searchValue : mixed
$returnColumn : mixed
$searchColumn : mixed
$expectedValue : mixed
$message : mixed

assertDBCompareValues()

Compare all values in a single retrieved DB record to an array of expected values.

public assertDBCompareValues(string $daoName, array<string|int, mixed> $searchParams, mixed $expectedValues) : mixed
Parameters
$daoName : string
$searchParams : array<string|int, mixed>
$expectedValues : mixed

assertDBNotNull()

Request a record from the DB by seachColumn+searchValue. Success if a record is found.

public assertDBNotNull(string $daoName, mixed $searchValue, mixed $returnColumn, mixed $searchColumn, mixed $message) : null|string
Parameters
$daoName : string
$searchValue : mixed
$returnColumn : mixed
$searchColumn : mixed
$message : mixed
Tags
throws
PHPUnit_Framework_AssertionFailedError
Return values
null|string

assertDBNull()

Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.

public assertDBNull(string $daoName, mixed $searchValue, mixed $returnColumn, mixed $searchColumn, mixed $message) : mixed
Parameters
$daoName : string
$searchValue : mixed
$returnColumn : mixed
$searchColumn : mixed
$message : mixed

assertDBQuery()

Assert that a SQL query returns a given value.

public assertDBQuery(string|null|int $expected, string $query[, array<string|int, mixed> $params = [] ][, string $message = '' ]) : void

The first argument is an expected value. The remaining arguments are passed to CRM_Core_DAO::singleValueQuery

Example: $this->assertSql(2, 'select count(*) from foo where foo.bar like "%1"', array(1 => array("Whiz", "String")));

Parameters
$expected : string|null|int
$query : string
$params : array<string|int, mixed> = []
$message : string = ''
Tags
noinspection

PhpUnhandledExceptionInspection

noinspection

PhpDocMissingThrowsInspection

assertDBRowExist()

Request a record from the DB by id. Success if row not found.

public assertDBRowExist(string $daoName, int $id[, null $message = NULL ]) : mixed
Parameters
$daoName : string
$id : int
$message : null = NULL

assertDBRowNotExist()

Request a record from the DB by id. Success if row not found.

public assertDBRowNotExist(string $daoName, int $id[, null $message = NULL ]) : mixed
Parameters
$daoName : string
$id : int
$message : null = NULL

assertDBState()

Generic function to compare expected values after an api call to retrieved.

public assertDBState(mixed $daoName, mixed $id, mixed $match[, bool $delete = FALSE ]) : void

DB values.

Parameters
$daoName : mixed
$id : mixed
$match : mixed
$delete : bool = FALSE
Tags
daoName

string DAO Name of object we're evaluating.

id

int Id of object

match

array Associative array of field name => expected value. Empty if asserting that a DELETE occurred

delete

boolean True if we're checking that a DELETE action occurred.


        
On this page

Search results