You are here

public function MailchimpListsBasicTestCase::testMailchimpListCRUD in Mailchimp 7.2

Tests Create, Read, Update, and Delete entity operations.

Current version tests everything but Delete operations.

Return value

bool Returns TRUE on completion.

File

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

Class

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

Code

public function testMailchimpListCRUD() {
  $test_lists = $this
    ->testLists();
  $saved_lists = entity_load_multiple_by_name('mailchimp_list', array_keys($test_lists));
  foreach ($saved_lists as $saved_list) {
    $test_list = $test_lists[$saved_list->name];
    $this
      ->assertEqual($saved_list->mc_list_id, $test_list->mc_list_id, 'MC List ids was saved correctly.');
    $this
      ->assertEqual($saved_list
      ->label(), $test_list->label, 'Label was saved correctly.');
    $this
      ->assertEqual($saved_list->description, $test_list->description, 'MC List ids were saved correctly.');
    foreach ($saved_list->settings as $key => $value) {
      $this
        ->assertEqual($value, $test_list->settings[$key], 'Setting ' . $key . ' matches.');
    }
    $this
      ->assertEqual($saved_list->mc_list_id, $test_list->mc_list_id, 'MC List ids were saved correctly.');
  }

  // Test list deletion.
  mailchimp_lists_delete_multiple(array_keys($test_lists));
  $this
    ->assertIdentical(mailchimp_lists_load_multiple(), array(), 'Lists have been deleted.');
}