Documentation

EventTestTrait

Helper for event tests.

This provides functions to set up valid events for unit tests.

The primary functions in this class are

  • eventCreatePaid
  • eventCreateUnpaid

Calling these function will create events with associated profiles and price set data as appropriate.

Table of Contents

Methods

addDiscountPriceSet()  : void
Add a discount price set to the given event.
eventCreate()  : array<string|int, mixed>
Create an Event.
eventCreatePaid()  : array<string|int, mixed>
Create a paid event.
eventCreateUnpaid()  : array<string|int, mixed>
Create an unpaid event.
getEvent()  : array<string|int, mixed>
This retrieves the values used to create the event.
getEventExampleData()  : array<string|int, mixed>
Get example data with which to create the event.
getEventID()  : int
Get the event id of the event created in set up.
getEventValue()  : mixed|null
Get a value from an event used in setup.
getPriceFieldOptions()  : array<string|int, array<string|int, mixed>>
Get the options for the price set.
updateEvent()  : void
Update an event.
addProfilesToEvent()  : void
Add profiles to the event.
createEventProfile()  : void
Create a profile attached to an event.
eventCreatePriceSet()  : void
Create a price set for an event.

Methods

addDiscountPriceSet()

Add a discount price set to the given event.

public addDiscountPriceSet([string $eventIdentifier = 'PaidEvent' ][, array<string|int, mixed> $discountParameters = [] ][, array<string|int, mixed> $priceSetParameters = [] ][, string $identifier = 'discount' ][, float $fraction = 0.5 ]) : void
Parameters
$eventIdentifier : string = 'PaidEvent'
$discountParameters : array<string|int, mixed> = []
$priceSetParameters : array<string|int, mixed> = []
$identifier : string = 'discount'
$fraction : float = 0.5
Tags
noinspection

PhpUnhandledExceptionInspection

noinspection

PhpDocMissingThrowsInspection

eventCreate()

Create an Event.

public eventCreate([array<string|int, mixed> $params = [] ][, string $identifier = 'event' ]) : array<string|int, mixed>

Note this is not expected to be called directly - call

  • eventCreatePaid
  • eventCreateUnpaid
Parameters
$params : array<string|int, mixed> = []

Name-value pair for an event.

$identifier : string = 'event'
Return values
array<string|int, mixed>

eventCreatePaid()

Create a paid event.

protected eventCreatePaid([array<string|int, mixed> $eventParameters = [] ][, array<string|int, mixed> $priceSetParameters = [] ][, string $identifier = 'PaidEvent' ]) : array<string|int, mixed>
Parameters
$eventParameters : array<string|int, mixed> = []

Values to

$priceSetParameters : array<string|int, mixed> = []
$identifier : string = 'PaidEvent'

Index for storing event ID in ids array.

Return values
array<string|int, mixed>

eventCreateUnpaid()

Create an unpaid event.

protected eventCreateUnpaid([array<string|int, mixed> $eventParameters = [] ][, string $identifier = 'event' ]) : array<string|int, mixed>
Parameters
$eventParameters : array<string|int, mixed> = []

Values to

$identifier : string = 'event'

Index for storing event ID in ids array.

Return values
array<string|int, mixed>

getEvent()

This retrieves the values used to create the event.

protected getEvent(string $identifier) : array<string|int, mixed>

Note this does not actually retrieve the event from the database although it arguably might be more useful.

Parameters
$identifier : string
Return values
array<string|int, mixed>

getEventExampleData()

Get example data with which to create the event.

protected getEventExampleData([string $name = 'PaidEvent' ]) : array<string|int, mixed>
Parameters
$name : string = 'PaidEvent'
Return values
array<string|int, mixed>

getEventID()

Get the event id of the event created in set up.

protected getEventID([string $identifier = 'event' ]) : int

If only one has been created it will be selected. Otherwise you should pass in the appropriate identifier.

Parameters
$identifier : string = 'event'
Return values
int

getEventValue()

Get a value from an event used in setup.

protected getEventValue(string $value, string $identifier) : mixed|null
Parameters
$value : string
$identifier : string
Return values
mixed|null

getPriceFieldOptions()

Get the options for the price set.

protected getPriceFieldOptions([string $identifier = 'PaidEvent' ]) : array<string|int, array<string|int, mixed>>
Parameters
$identifier : string = 'PaidEvent'

Optional string if we want to specify different options. This is not currently used but is consistent with our other functions and would allow over-riding.

Return values
array<string|int, array<string|int, mixed>>

updateEvent()

Update an event.

protected updateEvent([array<string|int, mixed> $eventParameters = [] ][, string $identifier = 'event' ]) : void
Parameters
$eventParameters : array<string|int, mixed> = []

Values to

$identifier : string = 'event'

Index for storing event ID in ids array.

addProfilesToEvent()

Add profiles to the event.

private addProfilesToEvent([string $identifier = 'event' ]) : void

This function is designed to reflect the normal use case where events do have profiles.

Note if any classes do not want profiles, or want something different, the thinking is they should override this. Once that arises we can review making it protected rather than private & checking we are happy with the signature.

Parameters
$identifier : string = 'event'
Tags
throws
CRM_Core_Exception

createEventProfile()

Create a profile attached to an event.

private createEventProfile(array<string|int, mixed> $profile, string $identifier[, bool $isAdditional = FALSE ]) : void
Parameters
$profile : array<string|int, mixed>
$identifier : string
$isAdditional : bool = FALSE
Tags
throws
CRM_Core_Exception

eventCreatePriceSet()

Create a price set for an event.

private eventCreatePriceSet(array<string|int, mixed> $priceSetParameters, string $identifier) : void
Parameters
$priceSetParameters : array<string|int, mixed>
$identifier : string

        
On this page

Search results