1 path.test PathSaveTest::testBackdropSaveOriginalPath()

Tests that path_save() makes the original path available to modules.

File

core/modules/simpletest/tests/path.test, line 315
Tests for path.inc.

Class

PathSaveTest
Tests the path_save() function.

Code

function testBackdropSaveOriginalPath() {
  $account = $this->backdropCreateUser();
  $uid = $account->uid;
  $name = $account->name;

  // Create a language-neutral alias.
  $path = array(
    'source' => "user/$uid",
    'alias' => 'foo',
  );
  $path_original = $path;
  path_save($path);

  // Alter the path.
  $path['alias'] = 'bar';
  path_save($path);

  // Test to see if the original alias is available to modules during
  // hook_path_update().
  $results = state_get('path_test_results', array());
  $this->assertIdentical($results['hook_path_update']['original']['alias'], $path_original['alias'], 'Old URL alias available to modules during hook_path_update.');
  $this->assertIdentical($results['hook_path_update']['original']['source'], $path_original['source'], 'Old URL alias available to modules during hook_path_update.');
}