You are here

public function MailchimpListsTestCase::testAddWebhook in Mailchimp 7.3

Same name and namespace in other branches
  1. 7.5 modules/mailchimp_lists/tests/mailchimp_lists.test \MailchimpListsTestCase::testAddWebhook()
  2. 7.4 modules/mailchimp_lists/tests/mailchimp_lists.test \MailchimpListsTestCase::testAddWebhook()

Tests adding a webhook to a list.

File

modules/mailchimp_lists/tests/mailchimp_lists.test, line 319
Test class and methods for the Mailchimp Lists module.

Class

MailchimpListsTestCase
@file Test class and methods for the Mailchimp Lists module.

Code

public function testAddWebhook() {
  $list_id = MAILCHIMP_LISTS_TEST_LIST_A;
  $url = 'http://example.org/web-hook-new';
  $actions = array(
    'subscribe' => TRUE,
  );
  $sources = array(
    'user' => TRUE,
    'admin' => TRUE,
    'api' => TRUE,
  );
  $webhook_added = mailchimp_webhook_add($list_id, $url, $actions, $sources);
  $this
    ->assertTrue($webhook_added, 'Tested webhook addition.');
  $found_webhook = FALSE;
  $webhooks = mailchimp_webhook_get($list_id);
  foreach ($webhooks as $webhook) {
    if ($webhook['url'] == $url) {
      $found_webhook = TRUE;
    }
  }
  $this
    ->assertTrue($found_webhook, 'Tested retrieval of new webhook.');
}