MailchimpListsWebhookTest.php in Mailchimp 8
File
modules/mailchimp_lists/src/Tests/MailchimpListsWebhookTest.php
View source
<?php
namespace Drupal\Tests\mailchimp_lists\Functional;
class MailchimpListsWebhookTest extends MailchimpListsTestBase {
public static $modules = [
'mailchimp',
'mailchimp_lists',
'mailchimp_test',
];
public function testGetWebhook() {
$list_id = '57afe96172';
$webhooks = mailchimp_webhook_get($list_id);
$this
->assertEqual($webhooks[0]->list_id, $list_id);
$this
->assertEqual($webhooks[0]->id, '37b9c73a88');
$this
->assertEqual($webhooks[0]->url, 'http://example.org');
$this
->assertEqual($webhooks[0]->events->subscribe, TRUE);
$this
->assertEqual($webhooks[0]->events->unsubscribe, FALSE);
$this
->assertEqual($webhooks[0]->sources->user, TRUE);
$this
->assertEqual($webhooks[0]->sources->api, FALSE);
}
public function testAddWebhook() {
$list_id = '57afe96172';
$url = 'http://example.org/web-hook-new';
$events = [
'subscribe' => TRUE,
];
$sources = [
'user' => TRUE,
'admin' => TRUE,
'api' => FALSE,
];
$webhook_id = mailchimp_webhook_add($list_id, $url, $events, $sources);
$this
->assertEqual($webhook_id, 'ab24521a00');
}
public function testDeleteWebhook() {
$list_id = '57afe96172';
$url = 'http://example.org';
$webhook_deleted = mailchimp_webhook_delete($list_id, $url);
$this
->assertTrue($webhook_deleted, 'Tested webhook deletion.');
}
}