You are here

function DashboardBlocksTestCase::testDisableEnable in Drupal 7

Tests that the dashboard module can be re-enabled, retaining its blocks.

File

modules/dashboard/dashboard.test, line 88
Tests for dashboard.module.

Class

DashboardBlocksTestCase
Tests the Dashboard module blocks.

Code

function testDisableEnable() {

  // Add a new custom block to a dashboard region.
  $custom_block = array();
  $custom_block['info'] = $this
    ->randomName(8);
  $custom_block['title'] = $this
    ->randomName(8);
  $custom_block['body[value]'] = $this
    ->randomName(32);
  $custom_block['regions[stark]'] = 'dashboard_main';
  $this
    ->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
  $this
    ->drupalGet('admin/dashboard');
  $this
    ->assertRaw($custom_block['title'], 'Block appears on the dashboard.');
  $edit = array();
  $edit['modules[Core][dashboard][enable]'] = FALSE;
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
  $this
    ->assertNoRaw('assigned to the invalid region', 'Dashboard blocks gracefully disabled.');
  module_list(TRUE);
  $this
    ->assertFalse(module_exists('dashboard'), 'Dashboard disabled.');
  $edit['modules[Core][dashboard][enable]'] = 'dashboard';
  $this
    ->drupalPost('admin/modules', $edit, t('Save configuration'));
  $this
    ->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
  module_list(TRUE);
  $this
    ->assertTrue(module_exists('dashboard'), 'Dashboard enabled.');
  $this
    ->drupalGet('admin/dashboard');
  $this
    ->assertRaw($custom_block['title'], 'Block still appears on the dashboard.');
}