So ideally I would have liked to get hook_path_alter() in before an URL alias is saved, but really the only thing that's blocking the D7 versions of both Pathauto and Redirect modules is that we need to know somehow about the original alias values when updating an alias (so if the alias changed, we can redirect from the soon-defunct alias). This works similar to our current comment/node/file/user saving in that they load in $entity->original before saving and invoking the insert or update hooks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Needs review
Issue tags: +pathauto, +redirect
FileSize
1.47 KB

Status: Needs review » Needs work

The last submitted patch, 998256-path-save-original.patch, failed testing.

Dave Reid’s picture

Status: Needs work » Needs review

I don't believe you test bot.

Dave Reid’s picture

#1: 998256-path-save-original.patch queued for re-testing.

Dave Reid’s picture

SilviuChingaru’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Novice, +Needs backport to D7

This would need to go into D8 first, no? Rerolling this for D8 would probably be a good novice task.

Also, could we get an automated test that tries to check for this?

justafish’s picture

Status: Needs work » Needs review
FileSize
4.43 KB

rerolled for D8 and test added

xjm’s picture

justafish -- Thanks! Want to upload the test in its own pach as well, to demonstrate its failure on the testbot without the fix?

xjm’s picture

Oh, one other thing. The tests look great (insofar as I can review on my phone), but the API docs are not quite standard. See http://drupal.org/node/1354 for reference. For example, the summaries for classes, functions, and methods should be one line, 80 chars or less, that begins with a verb. Also, it's a but weird to call the one a unit test when it's a web test case. Can we use DrupalUnitTestCase? If not let's change the summary a bit.

I'll also take a look in Dreditor after breakfast.

Thanks!

xjm’s picture

Status: Needs review » Needs work

Alright, so here are specific points for cleanup:

+++ b/core/modules/simpletest/tests/path.testundefined
@@ -333,3 +333,48 @@ class PathLookupTest extends DrupalWebTestCase {
+ * Unit test for path_save().
...
+   * Test that path_save() makes the original path available.

+++ b/core/modules/simpletest/tests/path_test.moduleundefined
@@ -0,0 +1,23 @@
+ * Reset/initialize the history of calls.

These should begin with third-person verbs.

+++ b/core/modules/simpletest/tests/path.testundefined
@@ -333,3 +333,48 @@ class PathLookupTest extends DrupalWebTestCase {
+  }
+  ¶
+  function setUp() {
...
+    path_save($path);
+    ¶
+    // Alter the path
+    $path['alias'] = 'bar';
+    path_save($path);
+    ¶

+++ b/core/modules/simpletest/tests/path_test.moduleundefined
@@ -0,0 +1,23 @@
+ */
+ ¶
...
+ ¶

Bits of trailing whitespace here.

+++ b/core/modules/simpletest/tests/path.testundefined
@@ -333,3 +333,48 @@ class PathLookupTest extends DrupalWebTestCase {
+    // Create a language neutral alias

There should be a period at the end of this comment. Also, minor grammar thing, but "language-neutral" should be hyphenated.

+++ b/core/modules/simpletest/tests/path_test.infoundefined
@@ -0,0 +1,6 @@
\ No newline at end of file

+++ b/core/modules/simpletest/tests/path_test.moduleundefined
@@ -0,0 +1,23 @@
\ No newline at end of file

Let's get a single newline at the end of these two files.

xjm’s picture

+++ b/core/modules/simpletest/tests/path.testundefined
@@ -333,3 +333,48 @@ class PathLookupTest extends DrupalWebTestCase {
+    // Create a language neutral alias
...
+    // Alter the path

Oh, and these two need to end in periods.

Sorry for all the noise!

justafish’s picture

Hi xjm, Thanks very much for the review! Hopefully I've fixed it all up..

Attached is the original patch rerolled for D8, the test to show it failing and the patch/test combined.

xjm’s picture

Status: Needs review » Needs work

Thanks @justafish! Looks like you got most of it. Thanks also for uploading the test-only patch to expose the failures on testbot.

The only remaining things are found are all really minor code style/grammar things:

  1. +++ b/core/modules/simpletest/tests/path.testundefined
    @@ -333,3 +333,49 @@ class PathLookupTest extends DrupalWebTestCase {
    +/**
    + * Tests path_save() function.
    + */
    

    This probably needs to be:

    Tests the path_save() function.

  2. +++ b/core/modules/simpletest/tests/path.testundefined
    @@ -333,3 +333,49 @@ class PathLookupTest extends DrupalWebTestCase {
    +    // Enable dummy module that implements hook_path_update.
    

    I think we can probably omit this comment (I looked a bit and didn't seen any precedent for adding a comment like this with other tests.)

  3. +++ b/core/modules/simpletest/tests/path.testundefined
    @@ -333,3 +333,49 @@ class PathLookupTest extends DrupalWebTestCase {
    +  /**
    +   * Tests path_save() makes the original path available to modules.
    +   */
    

    I think this needs to read:

    Tests that path_save() makes...

  4. +++ b/core/modules/simpletest/tests/path_test.infoundefined
    @@ -0,0 +1,6 @@
    +name = "Hook path tests"
    +description = "Support module for path hook testing."
    +package = Testing
    +version = VERSION
    +core = 8.x
    +hidden = TRUE
    \ No newline at end of file
    

    This file is still missing its terminal newline.

  5. +++ b/core/modules/simpletest/tests/path_test.moduleundefined
    @@ -0,0 +1,22 @@
    + * Dummy module implementing hook path.
    

    This should probably be:

    Dummy module implementing hook_path_update().

    Correct?

  6. +++ b/core/modules/simpletest/tests/path_test.moduleundefined
    @@ -0,0 +1,22 @@
    + * Resets the path test results
    

    There should be a period at the end of this summary.

justafish’s picture

Status: Needs work » Needs review
FileSize
4.26 KB
1.33 KB
2.93 KB

menu.test L113 and file.test L239 have comments pertaining to enabling dummy modules in their setUp functions. I actually found this very useful from menu.test when working out how to do this so I'm going to leave it in.

"Dummy module implementing hook path." is the exact same comment at the top of menu_test.module, but I've changed it to something more useful for future anyway.

New patches attached rerolled against head.

no_commit_credit’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
4.27 KB

Attached adds a grammar fix to an inline comment:

Enable a helper module that implements hook_path_update().

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @justafish!

I guess having a comment for the setUp() method is not consistent with most test cases that enable test-only modules, but if you think it's helpful, it doesn't hurt anything. :) I'll restrain my compulsion that we should put those inline comments in every other setUp() function if we do here. :P The comment at does at least need to be hook_path_update() with parens and have an article, like:

Enable a helper module that implements hook_path_update().

(Fixed in the patch above. Since these are just documentation cleanups it's okay to upload just a single patch for the subsequent rerolls, as we have the exposed failure in #13 to demonstrate the test for reviewers.)

I like the new file docblock; that is clearer as well.

Thanks for all your work on this. I think it's RTBC now.

justafish’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests, -Novice, -pathauto, -redirect, -Needs backport to D7, -Contributed project blocker
justafish’s picture

#15: 998256-path-save-original.patch queued for re-testing.

justafish’s picture

#15: 998256-path-save-combined.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests, +Novice, +pathauto, +redirect, +Needs backport to D7, +Contributed project blocker

The last submitted patch, 998256-path-save-combined.patch, failed testing.

justafish’s picture

Status: Needs work » Needs review
FileSize
4.27 KB

accounting for altered language key

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Hooray! Excellent job justafish on the tests and passes.

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Looks good. Committed/pushed to 8.x, moving back to 7.x.

Albert Volkman’s picture

Status: Patch (to be ported) » Needs review
FileSize
4.19 KB

D7 backport.

xjm’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests, -Novice

Backport is fine too.

Dave Reid’s picture

Assigned: Dave Reid » Unassigned

Yep looks good here too.

webflo’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/modules/simpletest/tests/path_test.infoundefined
@@ -0,0 +1,6 @@
+core = 8.x

Should be core 7.x. Right?

xjm’s picture

Hmmm how did that one slip through? Why would that pass testbot?

Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
4.19 KB

Yeah, definitely odd that that didn't get caught. Thanks @webflo!

xjm’s picture

I'm concerned about the testbot thing; it implies the test coverage is incomplete. We should try to debug why it didn't fail and either amend the test or open a followup issue, I think.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Alright, sun and chx clarified #31 on IRC. The core version compatibility isn't checked when simpletest enables a module, so it was being enabled properly in the test despite the .info file.

Albert Volkman’s picture

Thanks @xjm!

simpletest_knowledge++

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -pathauto, -redirect, -Needs backport to D7, -Contributed project blocker

Automatically closed -- issue fixed for 2 weeks with no activity.