$params = array(
'group' => array(
'IN' => array(
- '0' => 1,
- '1' => 26,
+ '0' => 'Test group C',
+ '1' => 'Test group D',
),
),
- 'contact_type' => 'Individual',
);
try{
'contact_id' => '3',
'contact_type' => 'Individual',
'contact_sub_type' => '',
- 'sort_name' => 'man2@yahoo.com',
- 'display_name' => 'man2@yahoo.com',
+ 'sort_name' => 'Groupmember, Test2',
+ 'display_name' => 'Test2 Groupmember',
'do_not_email' => 0,
'do_not_phone' => 0,
'do_not_mail' => 0,
'preferred_communication_method' => '',
'preferred_language' => 'en_US',
'preferred_mail_format' => 'Both',
- 'first_name' => '',
+ 'first_name' => 'Test2',
'middle_name' => '',
- 'last_name' => '',
+ 'last_name' => 'Groupmember',
'prefix_id' => '',
'suffix_id' => '',
'formal_title' => '',
'phone_type_id' => '',
'phone' => '',
'email_id' => '1',
- 'email' => 'man2@yahoo.com',
+ 'email' => 'test@example.org',
'on_hold' => 0,
'im_id' => '',
'provider_id' => '',
/*
* This example has been generated from the API test suite.
-* The test that created it is called "testGetGroupIDFromContact"
+* The test that created it is called "testContactGetWithGroupTitleMultipleGroups"
* and can be found at:
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
*
*/
public function testGetGroupIDFromContact() {
$groupId = $this->groupCreate();
- $description = "Get all from group and display contacts.";
- $subFile = "GroupFilterUsingContactAPI";
$params = array(
'email' => 'man2@yahoo.com',
'contact_type' => 'Individual',
$this->callAPISuccess('contact', 'create', $params);
// testing as integer
$params = array(
- 'group' => $groupId,
+ 'filter.group_id' => $groupId,
'contact_type' => 'Individual',
);
- $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+ $result = $this->callAPISuccess('contact', 'get', $params);
$this->assertEquals(1, $result['count']);
// group 26 doesn't exist, but we can still search contacts in it.
$params = array(
- 'group' => 26,
+ 'filter.group_id' => 26,
'contact_type' => 'Individual',
);
$this->callAPISuccess('contact', 'get', $params);
// testing as string
$params = array(
- 'group' => array($groupId, 26),
+ 'filter.group_id' => "$groupId, 26",
'contact_type' => 'Individual',
);
- $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+ $result = $this->callAPISuccess('contact', 'get', $params);
$this->assertEquals(1, $result['count']);
$params = array(
- 'group' => array(26, 27),
+ 'filter.group_id' => "26,27",
'contact_type' => 'Individual',
);
$this->callAPISuccess('contact', 'get', $params);
// testing as string
$params = array(
- 'group' => array('IN' => array($groupId, 26)),
+ 'filter.group_id' => array($groupId, 26),
'contact_type' => 'Individual',
);
- $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+ $result = $this->callAPISuccess('contact', 'get', $params);
$this->assertEquals(1, $result['count']);
//test in conjunction with other criteria
$params = array(
- 'group' => array($groupId, 26),
+ 'filter.group_id' => array($groupId, 26),
'contact_type' => 'Organization',
);
$this->callAPISuccess('contact', 'get', $params);
$params = array(
- 'group' => array(26, 27),
+ 'filter.group_id' => array(26, 27),
'contact_type' => 'Individual',
);
$result = $this->callAPISuccess('contact', 'get', $params);
* contact.get group=array('IN' => array('title1', 'title2)
*/
public function testContactGetWithGroupTitleMultipleGroups() {
+ $description = "Get all from group and display contacts.";
+ $subFile = "GroupFilterUsingContactAPI";
// Set up a contact, asser that they were created.
$contact_params = array(
'contact_type' => 'Individual',
foreach ($createdGroupsIds as $id) {
$this->assertContains((string) $id, $contact_groups);
}
+ $contact_get2 = $this->callAPIAndDocument('contact', 'get', array('group' => array('IN' => $createdGroupTitles)), __FUNCTION__, __FILE__, $description, $subFile);
$contact_get2 = $this->callAPISuccess('contact', 'get', array('group' => array('IN' => $createdGroupTitles), 'return' => 'group'));
$this->assertEquals($created_contact_id, $contact_get2['id']);
$contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']);