function testForceMailchimpToCiviSync() { $mailchimp_export_url = __DIR__ . '/../../../sample_mailchimp_export.txt'; $mailchimp_export_url = 'file:///' . realpath($mailchimp_export_url); $mailchimp_sync_setting = CRM_CiviMailchimp_BAO_SyncSettingsTest::createTestGroupAndSyncSettings('Test Group testForceMailchimpToCiviSync'); $mailchimp_members = CRM_CiviMailchimp_Form_Sync::forceMailchimpToCiviSync($mailchimp_export_url, $mailchimp_sync_setting); $contacts = CRM_Contact_BAO_Group::getGroupContacts($mailchimp_sync_setting->civicrm_group_id); $this->assertCount(3, $mailchimp_members); $this->assertCount(3, $contacts); }
/** * Test to check contact reference field */ public function testContactReference() { //create group $groupId1 = $this->groupCreate(); $groupId2 = $this->groupCreate(array('name' => 'Test Group 2', 'domain_id' => 1, 'title' => 'New Test Group2 Created', 'description' => 'New Test Group2 Created', 'is_active' => 1, 'visibility' => 'User and User Admin Only')); $contactIds = array(); foreach (array($groupId1, $groupId2) as $groupId) { $this->groupContactCreate($groupId); $contactIds = array_merge($contactIds, CRM_Contact_BAO_Group::getGroupContacts($groupId)); } $contactIds = CRM_Utils_Array::collect('contact_id', $contactIds); // create custom group with contact reference field $customGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'select_test_group')); $params = array('custom_group_id' => $customGroup['id'], 'name' => 'Worker_Lookup', 'label' => 'Worker Lookup', 'filter' => "action=lookup&group={$groupId1},{$groupId2}", 'html_type' => 'Autocomplete-Select', 'data_type' => 'ContactReference', 'weight' => 4, 'is_searchable' => 1, 'is_active' => 1); $customField = $this->callAPISuccess('custom_field', 'create', $params); $_GET = array('id' => $customField['id'], 'is_unit_test' => TRUE); $contactList = CRM_Contact_Page_AJAX::contactReference(); $contactList = CRM_Utils_Array::collect('id', $contactList); //assert each returned contact id to be present in group contact foreach ($contactList as $contactId) { $this->assertTrue(in_array($contactId, $contactIds)); } }
private function findTeamPlayers() { // find contacts in this group if (isset($this->_id)) { $groupContacts = CRM_Contact_BAO_Group::getGroupContacts($this->_id); if (count($groupContacts) > 0) { $this->_contactIds = array(); foreach ($groupContacts as $groupContact) { $this->_contactIds[] = $groupContact['contact_id']; } } } }