diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2012-02-28 23:53:31 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2012-02-28 23:53:31 -0800 |
commit | a11889c035b4e7b10af70caf2cba9fcc9201f9e1 (patch) | |
tree | f844fe9cada0d661cd9e7ac98b2cf26933502f10 /modules/simpletest | |
parent | 300a007c71b79692f5a48caeeba690b1eb3cefab (diff) | |
download | brdo-a11889c035b4e7b10af70caf2cba9fcc9201f9e1.tar.gz brdo-a11889c035b4e7b10af70caf2cba9fcc9201f9e1.tar.bz2 |
Issue #998256 by justafish, Albert Volkman, Dave Reid, no_commit_credit: Please let modules know about the original URL alias in hook_path_update().
Diffstat (limited to 'modules/simpletest')
-rw-r--r-- | modules/simpletest/tests/path.test | 46 | ||||
-rw-r--r-- | modules/simpletest/tests/path_test.info | 6 | ||||
-rw-r--r-- | modules/simpletest/tests/path_test.module | 23 |
3 files changed, 75 insertions, 0 deletions
diff --git a/modules/simpletest/tests/path.test b/modules/simpletest/tests/path.test index 8b3e6dc48..a506349dc 100644 --- a/modules/simpletest/tests/path.test +++ b/modules/simpletest/tests/path.test @@ -333,3 +333,49 @@ class PathLookupTest extends DrupalWebTestCase { $this->assertEqual(drupal_lookup_path('source', $path['alias']), $path['source'], t('Newer alias record is returned when comparing two LANGUAGE_NONE paths with the same alias.')); } } + +/** + * Tests the path_save() function. + */ +class PathSaveTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => t('Path save'), + 'description' => t('Tests that path_save() exposes the previous alias value.'), + 'group' => t('Path API'), + ); + } + + function setUp() { + // Enable a helper module that implements hook_path_update(). + parent::setUp('path_test'); + path_test_reset(); + } + + /** + * Tests that path_save() makes the original path available to modules. + */ + 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'], t('Old path alias available to modules during hook_path_update.')); + $this->assertIdentical($results['hook_path_update']['original']['source'], $path_original['source'], t('Old path alias available to modules during hook_path_update.')); + } +} diff --git a/modules/simpletest/tests/path_test.info b/modules/simpletest/tests/path_test.info new file mode 100644 index 000000000..ea993ae87 --- /dev/null +++ b/modules/simpletest/tests/path_test.info @@ -0,0 +1,6 @@ +name = "Hook path tests" +description = "Support module for path hook testing." +package = Testing +version = VERSION +core = 7.x +hidden = TRUE diff --git a/modules/simpletest/tests/path_test.module b/modules/simpletest/tests/path_test.module new file mode 100644 index 000000000..d3dc80e22 --- /dev/null +++ b/modules/simpletest/tests/path_test.module @@ -0,0 +1,23 @@ +<?php + +/** + * @file + * Helper module for the path tests. + */ + +/** + * Resets the path test results. + */ +function path_test_reset() { + variable_set('path_test_results', array()); +} + +/** + * Implements hook_path_update(). + */ +function path_test_path_update($path) { + $results = variable_get('path_test_results', array()); + $results['hook_path_update'] = $path; + variable_set('path_test_results', $results); +} + |