You are here

function PathRedirectFunctionalTest::testAliasRedirection in Path redirect 6

File

./path_redirect.test, line 203
Tests for the path_redirect module.

Class

PathRedirectFunctionalTest

Code

function testAliasRedirection() {
  $node = $this
    ->drupalCreateNode(array(
    'title' => 'test1',
  ));
  $edit = array(
    'path' => 'test1',
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('@type %title has been updated.', array(
    '@type' => 'Page',
    '%title' => $node->title,
  )), t('Node saved.'));
  $this
    ->assertFalse(path_redirect_load_multiple(NULL, array(
    'redirect' => 'node/' . $node->nid,
  )), t('No redirects created yet.'));
  $edit = array(
    'path' => 'test2',
  );
  $this
    ->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
  $this
    ->assertRaw(t('@type %title has been updated.', array(
    '@type' => 'Page',
    '%title' => $node->title,
  )), t('Node saved.'));
  $this
    ->assertTrue(path_redirect_load_multiple(NULL, array(
    'source' => 'test1',
    'redirect' => 'node/' . $node->nid,
  )), t('Redirect created.'));
  $this
    ->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
  $this
    ->assertFalse(path_redirect_load_multiple(NULL, array(
    'redirect' => 'node/' . $node->nid,
  )), t("Deleted node's redirects deleted."));
}