You are here

public function BmTestCtools::testSettingsPage in Backup and Migrate 7.3

Confirm automated settings exist.

File

tests/BmTestCtools.test, line 41
Test extended functionality as provided by Ctools.

Class

BmTestCtools
Class for testing CTools' extended functionality.

Code

public function testSettingsPage() {

  // Load the B&M Settings page.
  $this
    ->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings');
  $this
    ->assertResponse(200);

  // Does the mock schedule exist?
  $this
    ->assertText('Mock weekly database schedule');

  // Does the mock source exist?
  $this
    ->assertText('Mock file directory');

  // Does the mock destination exist?
  $this
    ->assertText('Mock e-mail destination');

  // Load the B&M Schedule page.
  $this
    ->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule');
  $this
    ->assertResponse(200);

  // Does the mock schedule exist?
  $this
    ->assertText('Mock weekly database schedule');

  // Does the mock schedule contain the appropriate values?
  $this
    ->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/schedule/edit/mock_db_weekly');
  $this
    ->assertResponse(200);
  $fields = _bm_test_get_mock_schedule();

  // @todo Deal with periods, but now I need sleep.
  // See the get_frequency_period() method in includes/schedules.inc.
  unset($fields['period']);

  // Test the destination selection with its own assertion.
  $this
    ->assertOptionSelected('edit-destination-id', $fields['destination_id']);
  unset($fields['destination_id']);
  foreach ($fields as $key => $field) {
    $id = 'edit-' . str_replace('_', '-', $key);
    $this
      ->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  }

  // Does the mock source contain the appropriate values?
  $this
    ->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/source/edit/mock_file_directory');
  $this
    ->assertResponse(200);
  $fields = _bm_test_get_mock_source();
  unset($fields['subtype']);
  foreach ($fields as $key => $field) {
    $id = 'edit-' . str_replace('_', '-', $key);
    $this
      ->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  }

  // Does the mock destination contain the appropriate values?
  $this
    ->drupalGet(BACKUP_MIGRATE_MENU_PATH . '/settings/destination/edit/mock_email');
  $this
    ->assertResponse(200);
  $fields = _bm_test_get_mock_destination();
  unset($fields['subtype']);
  foreach ($fields as $key => $field) {
    $id = 'edit-' . str_replace('_', '-', $key);
    $this
      ->assertFieldById($id, $field, 'Found field by id "' . $id . '" and value "' . $field . '".');
  }
}