$this->callAPISuccess('contact', 'delete', $contact);
}
+ /**
+ * Ensure consistent return format for option group fields.
+ */
+ public function testPseudoFields() {
+ $params = array(
+ 'preferred_communication_method' => array('Phone', 'SMS'),
+ 'preferred_language' => 'en_US',
+ 'gender_id' => 'Female',
+ 'prefix_id' => 'Mrs.',
+ 'suffix_id' => 'II',
+ 'communication_style_id' => 'Formal',
+ );
+
+ $contact = $this->callAPISuccess('contact', 'create', array_merge($this->_params, $params));
+
+ $result = $this->callAPISuccess('contact', 'getsingle', array('id' => $contact['id']));
+ $this->assertEquals('Both', $result['preferred_mail_format']);
+
+ $this->assertEquals('en_US', $result['preferred_language']);
+ $this->assertEquals(1, $result['communication_style_id']);
+ $this->assertEquals(1, $result['gender_id']);
+ $this->assertEquals('Female', $result['gender']);
+ $this->assertEquals('Mrs.', $result['individual_prefix']);
+ $this->assertEquals(1, $result['prefix_id']);
+ $this->assertEquals('II', $result['individual_suffix']);
+ $this->assertEquals(CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'suffix_id', 'II'), $result['suffix_id']);
+ $this->callAPISuccess('contact', 'delete', $contact);
+ $this->assertEquals(array(
+ CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'preferred_communication_method', 'Phone'),
+ CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'preferred_communication_method', 'SMS'),
+ ), $result['preferred_communication_method']);
+ }
+
+
/**
* Test birth date parameters.
*
* Test the duplicate check function.
*/
public function testDuplicateCheck() {
- $this->callAPISuccess('Contact', 'create', array(
+ $harry = array(
'first_name' => 'Harry',
'last_name' => 'Potter',
'email' => 'harry@hogwarts.edu',
'contact_type' => 'Individual',
- ));
+ );
+ $this->callAPISuccess('Contact', 'create', $harry);
$result = $this->callAPISuccess('Contact', 'duplicatecheck', array(
- 'match' => array(
- 'first_name' => 'Harry',
- 'last_name' => 'Potter',
- 'email' => 'harry@hogwarts.edu',
- 'contact_type' => 'Individual',
- ),
+ 'match' => $harry,
));
$this->assertEquals(1, $result['count']);
),
));
$this->assertEquals(0, $result['count']);
+ $this->callAPIFailure('Contact', 'create', array_merge($harry, array('dupe_check' => 1)));
}
public function testGetByContactType() {
$this->callAPISuccess('contact', 'delete', array('id' => $created_contact_id, 'skip_undelete' => TRUE));
}
+ public function testLoggedInUserAPISupportToken() {
+ $description = "Get contact id of the current logged in user";
+ $subFile = "ContactIDOfLoggedInUserContactAPI";
+ $cid = $this->createLoggedInUser();
+ $contact = $this->callAPIAndDocument('contact', 'get', array('id' => 'user_contact_id'), __FUNCTION__, __FILE__, $description, $subFile);
+ $this->assertEquals($cid, $contact['id']);
+ }
+
}