Documentation

CRMTraits_Event_ScenarioTrait uses trait:short

Trait to do set up for event scenarios.

This allows multiple test classes to act on various scenarios. e.g a user might complete a pending registration using the back office form, an api call or the horrible front end form overload method.

It might make sense to move this to Civi\Test for extensions to use but it might need to 'settle' a bit first as there is a balance to be found between accepting parameters & winding up with crazy complex functions.

Table of Contents

Properties

$sentMail  : array<string|int, mixed>
Mail sent during form submission.

Methods

addDiscountPriceSet()  : void
Add a discount price set to the given event.
eventCreate()  : array<string|int, mixed>
Create an Event.
createScenarioMultipleParticipantPendingFreeEvent()  : void
Create a participant registration with 2 registered_by participants.
createScenarioMultipleParticipantPendingWithTax()  : void
Create a participant registration with 2 registered_by participants.
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.

Properties

$sentMail

Mail sent during form submission.

protected array<string|int, mixed> $sentMail = []

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>

createScenarioMultipleParticipantPendingFreeEvent()

Create a participant registration with 2 registered_by participants.

protected createScenarioMultipleParticipantPendingFreeEvent() : void

This follows the front end form multiple participant flow with tax enabled.

Tags
throws
UnauthorizedException
throws
CRM_Core_Exception

createScenarioMultipleParticipantPendingWithTax()

Create a participant registration with 2 registered_by participants.

protected createScenarioMultipleParticipantPendingWithTax() : void

This follows the front end form multiple participant flow with tax enabled.

Tags
throws
UnauthorizedException
throws
CRM_Core_Exception

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