You are here

mailchimp_campaigns.test in Mailchimp 7.4

Test class and methods for the Mailchimp Campaigns module.

File

modules/mailchimp_campaign/tests/mailchimp_campaigns.test
View source
<?php

/**
 * @file
 * Test class and methods for the Mailchimp Campaigns module.
 */
class MailchimpCampaignsTestCase extends DrupalWebTestCase {

  /**
   * Returns info displayed in the test interface.
   *
   * @return array
   *   Formatted as specified by simpletest.
   */
  public static function getInfo() {

    // Note: getInfo() strings are not translated with t().
    return array(
      'name' => 'Mailchimp Campaigns',
      'description' => 'Test Campaigns Logic.',
      'group' => 'Mailchimp',
    );
  }

  /**
   * Pre-test setup function.
   *
   * Enables dependencies.
   * Sets the mailchimp_api_key to the test-mode key.
   * Sets test mode to TRUE.
   */
  protected function setUp() {

    // Use a profile that contains required modules:
    $prof = drupal_get_profile();
    $this->profile = $prof;

    // Enable modules required for the test.
    $enabled_modules = array(
      'libraries',
      'mailchimp',
      'entity',
      'entity_token',
      'mailchimp_campaign',
    );
    parent::setUp($enabled_modules);
    variable_set('mailchimp_api_key', 'MAILCHIMP_TEST_API_KEY');
    variable_set('mailchimp_test_mode', TRUE);
  }

  /**
   * Post-test function.
   *
   * Sets test mode to FALSE.
   */
  protected function tearDown() {
    parent::tearDown();
    variable_del('mailchimp_test_mode');
  }

  /**
   * Tests retrieval of a specific campaign.
   */
  public function testGetCampaign() {
    $campaign_id = '42694e9e57';
    $campaign = mailchimp_get_campaign_data($campaign_id);
    $this
      ->assertTrue(is_object($campaign), 'Tested retrieval of campaign data.');
    $this
      ->assertEqual($campaign->id, $campaign_id);
    $this
      ->assertEqual($campaign->type, 'regular');
    $this
      ->assertEqual($campaign->recipients->list_id, '57afe96172');
    $this
      ->assertEqual($campaign->settings->subject_line, 'Test Campaign');
    $this
      ->assertTrue($campaign->tracking->html_clicks);
    $this
      ->assertFalse($campaign->tracking->text_clicks);
  }

}

Classes

Namesort descending Description
MailchimpCampaignsTestCase @file Test class and methods for the Mailchimp Campaigns module.