You are here

mandrill_activity.test in Mandrill 7.2

Test class and methods for the Mandrill Activity module.

File

modules/mandrill_activity/tests/mandrill_activity.test
View source
<?php

/**
 * @file
 * Test class and methods for the Mandrill Activity module.
 */
class MandrillActivityTestCase 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' => 'Mandrill Activity Tests',
      'description' => 'Tests Mandrill Activity functionality.',
      'group' => 'Mandrill',
    );
  }

  /**
   * Pre-test setup function.
   *
   * Enables dependencies.
   * Sets the mandrill_api_key variable to the test key.
   */
  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',
      'mandrill',
      'mandrill_activity',
      'entity',
    );
    parent::setUp($enabled_modules);
    variable_set('mandrill_api_classname', 'DrupalMandrillTest');
    variable_set('mandrill_api_key', 'MANDRILL_TEST_API_KEY');
  }

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

  /**
   * Tests getting an array of message activity for a given email address.
   */
  public function testGetActivity() {
    $email = 'recipient@example.com';
    $activity = mandrill_activity_get_activity($email);
    $this
      ->assertTrue(!empty($activity), 'Tested retrieving activity.');
    if (!empty($activity) && is_array($activity)) {
      foreach ($activity as $message) {
        $this
          ->assertEqual($message['email'], $email, 'Tested valid message: ' . $message['subject']);
      }
    }
  }

}

Classes

Namesort descending Description
MandrillActivityTestCase @file Test class and methods for the Mandrill Activity module.