You are here

mandrill_reports.test in Mandrill 7.2

Test class and methods for the Mandrill Reports module.

File

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

/**
 * @file
 * Test class and methods for the Mandrill Reports module.
 */
class MandrillReportsTestCase 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 Reports Tests',
      'description' => 'Tests Mandrill Reports 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_reports',
      '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 Mandrill reports data.
   */
  public function testGetReportsData() {
    $reports_data = mandrill_reports_data();
    $this
      ->assertTrue(!empty($reports_data), 'Tested retrieving reports data.');
    $this
      ->assertTrue(!empty($reports_data['user']), 'Tested user report data exists.');
    $this
      ->assertTrue(!empty($reports_data['all_time_series']), 'Tested all time series report data exists.');
    $this
      ->assertTrue(!empty($reports_data['urls']), 'Tested URLs report data exists.');
  }

}

Classes

Namesort descending Description
MandrillReportsTestCase @file Test class and methods for the Mandrill Reports module.