6 class Contact
extends CiviUnitTestCase
{
8 * Helper function to create.
11 * @param array $params
14 * $contactID id of created contact
16 public static function create($params) {
17 require_once "CRM/Contact/BAO/Contact.php";
18 $contactID = CRM_Contact_BAO_Contact
::createProfileContact($params, CRM_Core_DAO
::$_nullArray);
23 * Helper function to create
24 * a contact of type Individual
26 * @param array $params
28 * $contactID id of created Individual
30 public static function createIndividual($params = NULL) {
31 //compose the params, when not passed
35 $contact_source = 'Testing purpose';
37 'first_name' => $first_name,
38 'last_name' => $last_name,
39 'contact_source' => $contact_source,
42 return self
::create($params);
46 * Helper function to create
47 * a contact of type Household
49 * @param array $params
51 * id of created Household
53 public static function createHousehold($params = NULL) {
54 //compose the params, when not passed
56 $household_name = "John Doe's home";
58 'household_name' => $household_name,
59 'contact_type' => 'Household',
62 require_once "CRM/Contact/BAO/Contact.php";
63 $household = CRM_Contact_BAO_Contact
::create($params);
64 return $household->id
;
68 * Helper function to create
69 * a contact of type Organisation
71 * @param array $params
73 * id of created Organisation
75 public static function createOrganisation($params = NULL) {
76 //compose the params, when not passed
78 $organization_name = "My Organization";
80 'organization_name' => $organization_name,
81 'contact_type' => 'Organization',
84 require_once "CRM/Contact/BAO/Contact.php";
85 $organization = CRM_Contact_BAO_Contact
::create($params);
86 return $organization->id
;
90 * Helper function to delete a contact.
92 * @param int $contactID
93 * Id of the contact to delete.
95 * true if contact deleted, false otherwise
97 public static function delete($contactID) {
98 require_once 'CRM/Contact/BAO/Contact.php';
99 return CRM_Contact_BAO_Contact
::deleteContact($contactID);