2 class Contact
extends CiviUnitTestCase
{
4 * Helper function to create
9 * @return int $contactID id of created contact
11 static function create($params) {
12 require_once "CRM/Contact/BAO/Contact.php";
13 $contactID = CRM_Contact_BAO_Contact
::createProfileContact($params, CRM_Core_DAO
::$_nullArray);
18 * Helper function to create
19 * a contact of type Individual
22 * @return int $contactID id of created Individual
24 static function createIndividual($params = NULL) {
25 //compose the params, when not passed
29 $contact_source = 'Testing purpose';
31 'first_name' => $first_name,
32 'last_name' => $last_name,
33 'contact_source' => $contact_source,
36 return self
::create($params);
40 * Helper function to create
41 * a contact of type Household
44 * @return mixed $contactID id of created Household
46 static function createHousehold($params = NULL) {
47 //compose the params, when not passed
49 $household_name = "John Doe's home";
51 'household_name' => $household_name,
52 'contact_type' => 'Household',
55 require_once "CRM/Contact/BAO/Contact.php";
56 $household = CRM_Contact_BAO_Contact
::create($params);
57 return $household->id
;
61 * Helper function to create
62 * a contact of type Organisation
65 * @return mixed $contactID id of created Organisation
67 static function createOrganisation($params = NULL) {
68 //compose the params, when not passed
70 $organization_name = "My Organization";
72 'organization_name' => $organization_name,
73 'contact_type' => 'Organization',
76 require_once "CRM/Contact/BAO/Contact.php";
77 $organization = CRM_Contact_BAO_Contact
::create($params);
78 return $organization->id
;
82 * Helper function to delete a contact
84 * @param int $contactID id of the contact to delete
85 * @return boolean true if contact deleted, false otherwise
87 static function delete($contactID) {
88 require_once 'CRM/Contact/BAO/Contact.php';
89 return CRM_Contact_BAO_Contact
::deleteContact($contactID);