You are here

function PathSaveTest::testDrupalSaveOriginalPath in Drupal 7

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

File

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

Class

PathSaveTest
Tests the path_save() function.

Code

function testDrupalSaveOriginalPath() {
  $account = $this
    ->drupalCreateUser();
  $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 = variable_get('path_test_results', array());
  $this
    ->assertIdentical($results['hook_path_update']['original']['alias'], $path_original['alias'], 'Old path alias available to modules during hook_path_update.');
  $this
    ->assertIdentical($results['hook_path_update']['original']['source'], $path_original['source'], 'Old path alias available to modules during hook_path_update.');
}