trait ContactTestTrait

Class ContactTestTrait

Methods

int
createLoggedInUser()

Emulate a logged in user since certain functions use that.

int
organizationCreate(array $params = [], int $seq = 0)

Generic function to create Organisation, to be used in test cases

int
individualCreate(array $params = [], int $seq = 0, bool $random = FALSE)

Generic function to create Individual, to be used in test cases

int
householdCreate(array $params = [], int $seq = 0)

Generic function to create Household, to be used in test cases

array
sampleContact(string $contact_type, int $seq = 0, bool $random = FALSE)

Helper function for getting sample contact properties.

contactDelete(int $contactID)

Delete contact, ensuring it is not the domain contact

int
groupCreate(array $params = [])

Add a Group.

groupDelete(int $gid)

Delete a Group.

int
groupContactCreate(int $groupID, int $totalCount = 10, bool $random = FALSE)

Function to add a Group.

Details

at line 26
int createLoggedInUser()

Emulate a logged in user since certain functions use that.

value to store a record in the DB (like activity) CRM-8180

Return Value

int Contact ID of the created user.

at line 56
int organizationCreate(array $params = [], int $seq = 0)

Generic function to create Organisation, to be used in test cases

Parameters

array $params parameters for civicrm_contact_add api function call
int $seq sequence number if creating multiple organizations

Return Value

int id of Organisation created

at line 78
int individualCreate(array $params = [], int $seq = 0, bool $random = FALSE)

Generic function to create Individual, to be used in test cases

Parameters

array $params parameters for civicrm_contact_add api function call
int $seq sequence number if creating multiple individuals
bool $random

Return Value

int id of Individual created

Exceptions

CRM_Core_Exception

at line 96
int householdCreate(array $params = [], int $seq = 0)

Generic function to create Household, to be used in test cases

Parameters

array $params parameters for civicrm_contact_add api function call
int $seq sequence number if creating multiple households

Return Value

int id of Household created

Exceptions

CRM_Core_Exception

at line 113
array sampleContact(string $contact_type, int $seq = 0, bool $random = FALSE)

Helper function for getting sample contact properties.

Parameters

string $contact_type enum contact type: Individual, Organization
int $seq sequence number for the values of this type
bool $random

Return Value

array properties of sample contact (ie. $params for API call)

at line 176
contactDelete(int $contactID)

Delete contact, ensuring it is not the domain contact

Parameters

int $contactID Contact ID to delete

at line 195
int groupCreate(array $params = [])

Add a Group.

Parameters

array $params

Return Value

int groupId of created group

at line 218
groupDelete(int $gid)

Delete a Group.

Parameters

int $gid

at line 238
int groupContactCreate(int $groupID, int $totalCount = 10, bool $random = FALSE)

Function to add a Group.

Parameters

int $groupID
int $totalCount
bool $random

Return Value

int groupId of created group