ExampleTransactionalTest
extends TestCase
in package
implements
HeadlessInterface, TransactionalInterface
This is an example of a barebones test which uses a transaction (based on CiviTestListener).
We check that the transaction works by creating some example records in setUp(). These records should fetchable while the test executes, but not during tearDownAfterClass().
Tags
Table of Contents
Interfaces
- HeadlessInterface
- Interface HeadlessInterface
- TransactionalInterface
- Interface HeadlessInterface
Properties
- $contactIds : array<string|int, mixed>
Methods
- setUpHeadless() : mixed
- The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
- tearDownAfterClass() : void
- Both testDummy1 and testDummy2 have been created at some point (as part of the test runs), but all the data was rolled-back
- testDummy1() : void
- In the first test, we make make testDummy1. He exists.
- testDummy2() : void
- We previously made testDummy1, but he's been lost (rolled-back).
- setUp() : void
Properties
$contactIds
protected
static array<string|int, mixed>
$contactIds
= []
Array(int $id).
Methods
setUpHeadless()
The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
public
setUpHeadless() : mixed
It should perform any necessary steps required for putting the database in a consistent baseline -- such as loading schema and extensions.
The utility \Civi\Test::headless()
provides a number of helper functions
for managing this setup, and it includes optimizations to avoid redundant
setup work.
tearDownAfterClass()
Both testDummy1 and testDummy2 have been created at some point (as part of the test runs), but all the data was rolled-back
public
static tearDownAfterClass() : void
Tags
testDummy1()
In the first test, we make make testDummy1. He exists.
public
testDummy1() : void
testDummy2()
We previously made testDummy1, but he's been lost (rolled-back).
public
testDummy2() : void
However, testDummy2 now exists.
setUp()
protected
setUp() : void