ExampleSubscriberTest
extends TestCase
in package
implements
HeadlessInterface, EventSubscriberInterface
This is an example of a barebones test which implements `EventSubscriberInterface`. The method `getSubscribedEvents()` is used to get a list of listeners.
The underlying mechanism behind this is:
- When booting headless Civi,
CRM_Utils_System_UnitTests::initialize()
looks up the active test object. - It uses
EventScanner
to check the interfaces & methods for any listeners.
Tags
Table of Contents
Interfaces
- HeadlessInterface
- Interface HeadlessInterface
- EventSubscriberInterface
Properties
- $contact : CRM_Contact_DAO_Contact
- $tracker : mixed
Methods
- getSubscribedEvents() : mixed
- myAlterContentObject() : void
- myAlterContentParams() : mixed
- myCacheClear() : void
- myCiviApiPrepare() : void
- myCiviApiResolve() : void
- setUpHeadless() : mixed
- The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
- testCacheClearEvent() : void
- testGetFields() : void
- testPageOutput() : void
- setUp() : void
- tearDown() : void
Properties
$contact
protected
CRM_Contact_DAO_Contact
$contact
$tracker
protected
mixed
$tracker
Methods
getSubscribedEvents()
public
static getSubscribedEvents() : mixed
myAlterContentObject()
public
myAlterContentObject(GenericHookEvent $event) : void
Parameters
- $event : GenericHookEvent
myAlterContentParams()
public
myAlterContentParams(mixed &$content, mixed $context, mixed $tplName, mixed &$object) : mixed
Parameters
- $content : mixed
- $context : mixed
- $tplName : mixed
- $object : mixed
myCacheClear()
public
myCacheClear(GenericHookEvent $event) : void
Parameters
- $event : GenericHookEvent
myCiviApiPrepare()
public
myCiviApiPrepare(PrepareEvent $event) : void
Parameters
- $event : PrepareEvent
myCiviApiResolve()
public
myCiviApiResolve(ResolveEvent $event) : void
Parameters
- $event : ResolveEvent
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.
testCacheClearEvent()
public
testCacheClearEvent() : void
testGetFields()
public
testGetFields() : void
testPageOutput()
public
testPageOutput() : void
setUp()
protected
setUp() : void
tearDown()
protected
tearDown() : void