/** * Tests the mapping of group and interest names as posted by Mailchimp * Webhook to CiviCRM Group IDs. * * CiviCRM groups via ... provides Foo,Bar,Baz * Mailchimp Webhook POST provides Foo, Bar, Baz * * @depends testGetMCInterestGroupings * @group interests */ public function testSplitMailchimpWebhookGroupsToCiviGroupIds() { $sync = new CRM_Mailchimp_Sync(static::$test_list_id); $i = static::MC_INTEREST_NAME_1; $j = static::MC_INTEREST_NAME_2; $cases = ["{$i}" => [static::$civicrm_group_id_interest_1], "{$i}, {$j}" => [static::$civicrm_group_id_interest_1, static::$civicrm_group_id_interest_2], "{$j}, another interest, {$i}, and another" => [static::$civicrm_group_id_interest_1, static::$civicrm_group_id_interest_2], "other list name, {$j}, {$i}, and another" => [static::$civicrm_group_id_interest_1, static::$civicrm_group_id_interest_2], "other list name,and another" => [], "" => []]; foreach ($cases as $input => $expected) { $ints = $sync->SplitMailchimpWebhookGroupsToCiviGroupIds($input); $this->assertEquals($expected, $ints, "mapping failed for test '{$input}'"); } // We didn't change the fixture. static::$fixture_should_be_reset = FALSE; }