2 class Contact
extends CiviUnitTestCase
{
4 * Helper function to create
7 * @return $contactID id of created contact
9 static function create($params) {
10 require_once "CRM/Contact/BAO/Contact.php";
11 $contactID = CRM_Contact_BAO_Contact
::createProfileContact($params, CRM_Core_DAO
::$_nullArray);
16 * Helper function to create
17 * a contact of type Individual
19 * @return $contactID id of created Individual
21 static function createIndividual($params = NULL) {
22 //compose the params, when not passed
26 $contact_source = 'Testing purpose';
28 'first_name' => $first_name,
29 'last_name' => $last_name,
30 'contact_source' => $contact_source,
33 return self
::create($params);
37 * Helper function to create
38 * a contact of type Household
40 * @return $contactID id of created Household
42 static function createHousehold($params = NULL) {
43 //compose the params, when not passed
45 $household_name = "John Doe's home";
47 'household_name' => $household_name,
48 'contact_type' => 'Household',
51 require_once "CRM/Contact/BAO/Contact.php";
52 $household = CRM_Contact_BAO_Contact
::create($params);
53 return $household->id
;
57 * Helper function to create
58 * a contact of type Organisation
60 * @return $contactID id of created Organisation
62 static function createOrganisation($params = NULL) {
63 //compose the params, when not passed
65 $organization_name = "My Organization";
67 'organization_name' => $organization_name,
68 'contact_type' => 'Organization',
71 require_once "CRM/Contact/BAO/Contact.php";
72 $organization = CRM_Contact_BAO_Contact
::create($params);
73 return $organization->id
;
77 * Helper function to delete a contact
79 * @param int $contactID id of the contact to delete
80 * @return boolean true if contact deleted, false otherwise
82 static function delete($contactID) {
83 require_once 'CRM/Contact/BAO/Contact.php';
84 return CRM_Contact_BAO_Contact
::deleteContact($contactID);