Test
in package
Class Test
A facade for managing the test environment.
Table of Contents
Properties
- $statics : array<string|int, mixed>
- $singletons : array<string|int, mixed>
Methods
- asPreInstall() : mixed
- Run code in a pre-boot fashion.
- codeGen() : CRM_Core_CodeGen_Main
- data() : Data
- dsn() : string|array<string|int, mixed>|null
- Get the data source used for testing.
- e2e() : CiviEnvBuilder
- Create a builder for end-to-end testing on the live environment.
- eventChecker() : EventChecker
- example() : array<string|int, mixed>
- Lookup the content of an example data-set.
- examples() : ExampleDataLoader
- execute() : bool
- Prepare and execute a batch of SQL statements.
- headless() : CiviEnvBuilder
- Create a builder for the headless environment.
- pdo() : PDO
- Get a connection to the test database.
- schema() : Schema
Properties
$statics
public
static array<string|int, mixed>
$statics
= []
$singletons
private
static array<string|int, mixed>
$singletons
= []
Methods
asPreInstall()
Run code in a pre-boot fashion.
public
static asPreInstall(callable $callback) : mixed
Parameters
- $callback : callable
Return values
mixed —Pass through the result of the callback.
codeGen()
public
static codeGen() : CRM_Core_CodeGen_Main
Return values
CRM_Core_CodeGen_Maindata()
public
static data() : Data
Return values
Datadsn()
Get the data source used for testing.
public
static dsn([string|null $part = NULL ]) : string|array<string|int, mixed>|null
Parameters
- $part : string|null = NULL
-
One of NULL, 'hostspec', 'port', 'username', 'password', 'database'.
Return values
string|array<string|int, mixed>|null —If $part is omitted, return full DSN array. If $part is a string, return that part of the DSN.
e2e()
Create a builder for end-to-end testing on the live environment.
public
static e2e() : CiviEnvBuilder
\Civi\Test::e2e()->apply();
\Civi\Test::e2e()->install('foo.bar')->apply();
Return values
CiviEnvBuildereventChecker()
public
static eventChecker() : EventChecker
Return values
EventCheckerexample()
Lookup the content of an example data-set.
public
static example(string $name) : array<string|int, mixed>
This helper is for the common case of looking up the data for a specific example.
If you need more detailed information (eg the list of examples or other metadata),
then use \Civi\Test::examples(): ExampleDataLoader
. It provides more methods.
Parameters
- $name : string
-
Symbolic name of the data-set.
Return values
array<string|int, mixed> —The example data.
examples()
public
static examples() : ExampleDataLoader
Return values
ExampleDataLoaderexecute()
Prepare and execute a batch of SQL statements.
public
static execute(string $query) : bool
Parameters
- $query : string
Return values
boolheadless()
Create a builder for the headless environment.
public
static headless() : CiviEnvBuilder
\Civi\Test::headless()->apply();
\Civi\Test::headless()->sqlFile('ex.sql')->apply();
Return values
CiviEnvBuilderpdo()
Get a connection to the test database.
public
static pdo() : PDO
Return values
PDOschema()
public
static schema() : Schema