6 class Contact
extends CiviUnitTestCase
{
8 * Helper function to create
11 * @param array $params
13 * @return int $contactID id of created contact
15 static function create($params) {
16 require_once "CRM/Contact/BAO/Contact.php";
17 $contactID = CRM_Contact_BAO_Contact
::createProfileContact($params, CRM_Core_DAO
::$_nullArray);
22 * Helper function to create
23 * a contact of type Individual
25 * @param array $params
26 * @return int $contactID id of created Individual
28 static function createIndividual($params = NULL) {
29 //compose the params, when not passed
33 $contact_source = 'Testing purpose';
35 'first_name' => $first_name,
36 'last_name' => $last_name,
37 'contact_source' => $contact_source,
40 return self
::create($params);
44 * Helper function to create
45 * a contact of type Household
47 * @param array $params
48 * @return mixed $contactID id of created Household
50 static function createHousehold($params = NULL) {
51 //compose the params, when not passed
53 $household_name = "John Doe's home";
55 'household_name' => $household_name,
56 'contact_type' => 'Household',
59 require_once "CRM/Contact/BAO/Contact.php";
60 $household = CRM_Contact_BAO_Contact
::create($params);
61 return $household->id
;
65 * Helper function to create
66 * a contact of type Organisation
68 * @param array $params
69 * @return mixed $contactID id of created Organisation
71 static function createOrganisation($params = NULL) {
72 //compose the params, when not passed
74 $organization_name = "My Organization";
76 'organization_name' => $organization_name,
77 'contact_type' => 'Organization',
80 require_once "CRM/Contact/BAO/Contact.php";
81 $organization = CRM_Contact_BAO_Contact
::create($params);
82 return $organization->id
;
86 * Helper function to delete a contact
88 * @param int $contactID id of the contact to delete
89 * @return boolean true if contact deleted, false otherwise
91 static function delete($contactID) {
92 require_once 'CRM/Contact/BAO/Contact.php';
93 return CRM_Contact_BAO_Contact
::deleteContact($contactID);