/** * New contacts and profile changes need bringing into CiviCRM. */ public static function syncPullFromMailchimp(CRM_Queue_TaskContext $ctx, $listID, $dry_run) { // Do the batch update. Might take a while :-O $sync = new CRM_Mailchimp_Sync($listID); $sync->dry_run = $dry_run; // this generates updates and group changes. $stats[$listID] = $sync->updateCiviFromMailchimp(); // Finally, finish up by removing the two temporary tables // @todo re-enable this: CRM_Mailchimp_Sync::dropTemporaryTables(); static::updatePullStats($stats); return CRM_Queue_Task::TASK_SUCCESS; }
/** * */ public function testPullIgnoresDuplicates() { try { $this->createTitanic(); // Now pull sync. $sync = new CRM_Mailchimp_Sync(static::$test_list_id); // Collect data from CiviCRM. $sync->collectCiviCrm('pull'); $this->assertEquals(0, $sync->countCiviCrmMembers()); // Collect from Mailchimp. $sync->collectMailchimp('pull'); $this->assertEquals(1, $sync->countMailchimpMembers()); // Nothing should be matchable. $matches = $sync->matchMailchimpMembersToContacts(); $this->assertEquals(['bySubscribers' => 0, 'byUniqueEmail' => 0, 'byNameEmail' => 0, 'bySingle' => 0, 'totalMatched' => 0, 'newContacts' => 0, 'failures' => 1], $matches); // Nothing is insync. $in_sync = $sync->removeInSync('pull'); $this->assertEquals(0, $in_sync); // Update CiviCRM - nothing should be changed. $stats = $sync->updateCiviFromMailchimp(); $this->assertEquals(['created' => 0, 'joined' => 0, 'in_sync' => 0, 'removed' => 0, 'updated' => 0], $stats); } catch (CRM_Mailchimp_Exception $e) { // Spit out request and response for debugging. print "Request:\n"; print_r($e->request); print "Response:\n"; print_r($e->response); // re-throw exception. throw $e; } }