Documentation

ExampleHookTest extends TestCase
in package
implements HeadlessInterface, HookInterface

This is an example of a barebones test which implements `HookInterface`. Methods are automatically scanned to find event-listeners based on a naming convention:

  • function hook_*($arg1, &$arg2, ...): Bind to eponymous hook. Receive a list of ordered parameters.
  • 'function on_*($event)`: Bind to eponymous Symfony event. Receive an event object.

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
group

headless

Table of Contents

Interfaces

HeadlessInterface
Interface HeadlessInterface
HookInterface

Properties

$contact  : CRM_Contact_DAO_Contact
$tracker  : mixed

Methods

hook_civicrm_alterContent()  : mixed
Listen to hook_civicrm_alterContent in traditional hook format.
on_civi_api_prepare()  : void
Listen to `civi.api.resolve` in Symfony event format.
on_civi_api_resolve()  : void
Listen to `civi.api.resolve` in Symfony event format.
on_hook_civicrm_alterContent()  : void
Listen to hook_civicrm_alterContent in Symfony event format.
setUpHeadless()  : mixed
The setupHeadless function runs at the start of each test case, right before the headless environment reboots.
testGetFields()  : void
Test getfields calls hooks.
testPageOutput()  : void
Basic run test.
setUp()  : void
tearDown()  : void

Properties

Methods

hook_civicrm_alterContent()

Listen to hook_civicrm_alterContent in traditional hook format.

public hook_civicrm_alterContent(mixed &$content, mixed $context, mixed $tplName, mixed &$object) : mixed
Parameters
$content : mixed
$context : mixed
$tplName : mixed
$object : mixed
Tags
see
CRM_Utils_Hook::alterContent

on_hook_civicrm_alterContent()

Listen to hook_civicrm_alterContent in Symfony event format.

public on_hook_civicrm_alterContent(GenericHookEvent $event) : void
Parameters
$event : GenericHookEvent
Tags
see
CRM_Utils_Hook::alterContent

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.


        
On this page

Search results