You are here

function RedirectFunctionalTest::testDisableEnableRedirect in Redirect 7

Same name and namespace in other branches
  1. 7.2 redirect.test \RedirectFunctionalTest::testDisableEnableRedirect()

File

./redirect.test, line 323
Unit tests for the redirect module.

Class

RedirectFunctionalTest

Code

function testDisableEnableRedirect() {

  // Add a new redirect.
  $redirect = $this
    ->addRedirect('redirect', 'node');

  // Check that it is enabled.
  $this
    ->assertEqual($redirect->status, 1);

  // Disable the redirect.
  $edit = array(
    'status' => FALSE,
  );
  $this
    ->drupalPost("admin/config/search/redirect/edit/{$redirect->rid}", $edit, t('Save'));
  $redirect = redirect_load($redirect->rid);

  // Check that it has been disabled.
  $this
    ->assertEqual($redirect->status, 0);
  $this
    ->drupalGet("admin/config/search/redirect/edit/{$redirect->rid}");
  $this
    ->assertNoFieldChecked('edit-status', 'status is unchecked');
  $this
    ->assertNoRedirect($redirect);

  // Re-enable the redirect.
  $edit = array(
    'status' => 1,
  );
  $this
    ->drupalPost("admin/config/search/redirect/edit/{$redirect->rid}", $edit, t('Save'));
  $this
    ->assertRedirect($redirect);
}