コード例 #1
0
 /**
  * Tests CRM_Mailchimp_Utils::splitGroupTitlesFromMailchimp.
  *
  * Similar data as above except that:
  *
  * - it's the Mailchimp `interest_name` that's used for comparison.
  *
  * - titles from the Mailchimp API are comma-space separated and commas in
  *   names are escaped with `\`
  *
  */
 public function testGroupTitleSplittingFromMailchimp()
 {
     $groups = [1 => ['is_mc_update_grouping' => 1, 'interest_name' => 'sponsored walk'], 2 => ['is_mc_update_grouping' => 1, 'interest_name' => 'sponsored walk, 2015'], 3 => ['is_mc_update_grouping' => 1, 'interest_name' => 'Never used'], 3 => ['is_mc_update_grouping' => 0, 'interest_name' => 'Invalid - not is_mc_update_grouping']];
     $tests = ['aye, sponsored walk' => [1], 'aye, sponsored walk, bee' => [1], 'sponsored walk, bee' => [1], 'sponsored walk, sponsored walk\\, 2015' => [1, 2], 'sponsored walk' => [1], 'sponsored walk\\, 2015' => [2], 'Invalid - not is_mc_update_grouping' => []];
     foreach ($tests as $input => $expected) {
         $result = CRM_Mailchimp_Utils::splitGroupTitlesFromMailchimp($input, $groups);
         sort($result);
         $this->assertEquals($expected, $result, "Test case '{$input}' failed");
     }
 }
コード例 #2
0
 /**
  * Convert an 'INTERESTS' string as provided by Mailchimp's Webhook POST to
  * an array of CiviCRM group ids.
  *
  * Nb. a Mailchimp webhook is the equivalent of a 'pull' operation so we
  * ignore any groups that Mailchimp is not allowed to update.
  *
  * @param string $group_input
  *   As POSTed to Webhook in Mailchimp's merges.INTERESTS data.
  * @return array CiviCRM group IDs.
  */
 public function splitMailchimpWebhookGroupsToCiviGroupIds($group_input)
 {
     return CRM_Mailchimp_Utils::splitGroupTitlesFromMailchimp($group_input, $this->interest_group_details);
 }