1.20.x system.test DeprecatedRedirectPageCase::testRedirects()

Tests redirecting from a old menu paths to new menu paths.

File

modules/system/tests/system.test, line 1025
Tests for system.module.

Class

DeprecatedRedirectPageCase

Code

function testRedirects() {
  // Message used in watchdog entries.
  $watchdog_message = 'The path %path has been deprecated and will be removed in the next major release of Backdrop. This path was called from %referrer. It is recommended to remove it from any existing links.';

  // Check simple path redirection with no wildcards.
  $this->backdropGet('old/path/simple');
  $this->assertText('Current path: new/path/simple');
  $this->assertWatchdogMessage($watchdog_message, array(
    '%path' => 'old/path/simple',
    '%referrer' => '',
  ), 'Deprecated watchdog message found for simple redirect.');

  // Check path redirection with an implied one-to-one argument map.
  $this->backdropGet('old/path/foo/same/bar/positions/baz');
  $this->assertText('Current path: new/path/foo/with/bar/wildcards/baz');
  $this->assertWatchdogMessage($watchdog_message, array(
    '%path' => 'old/path/foo/same/bar/positions/baz',
    '%referrer' => '',
  ), 'Deprecated watchdog message found for an implied argument map redirect.');

  // Check path redirection with a specified argument map.
  $this->backdropGet('old/path/different/foo/wildcard/bar/baz/positions');
  $this->assertText('Current path: new/path/foo/with/bar/wildcards/baz');
  $this->assertWatchdogMessage($watchdog_message, array(
    '%path' => 'old/path/different/foo/wildcard/bar/baz/positions',
    '%referrer' => '',
  ), 'Deprecated watchdog message found for an argument map redirect.');
}