Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As noticed in #1831632: Convert node_rank_ $rank variables to use configuration system there should be a test for the UI that controls the node_rank_$rank variables (or their future CMI replacements). The existing tests for search ranking set the variables/config directly instead of using the UI, so the UI is never directly tested.
Comment | File | Size | Author |
---|---|---|---|
#13 | 2132647-11-13-interdiff.txt | 1.48 KB | ianthomas_uk |
#13 | 2132647-nodesearch-settings-test-13.patch | 3.3 KB | ianthomas_uk |
#11 | 2132647-nodesearch-settings-test-11.patch | 3.28 KB | ianthomas_uk |
#11 | 2132647-9-11-interdiff.txt | 2.34 KB | ianthomas_uk |
#9 | human-git-interdiff.txt | 1.13 KB | ianthomas_uk |
Comments
Comment #1
ianthomas_ukHere's a test
Comment #2
jhodgdonAll this tests is that if you change the settings on the settings form, the next time you go to the form the numbers are updated.
It needs to test whether this actually affects searching in the desired way.
Comment #3
ianthomas_ukI suggested to jhodgson on IRC that the node creation should be moved to setUp(), but have since changed my mind as the various tests using different very different nodes and it just made the tests harder to read.
The attached patch therefore just converts the first test to use the UI rather than modifing the variables directly. I've also commented out some unnecessary setup that wasn't being used in the test (designed for views/comments testing).
No interdiff as it's a new approach.
Comment #5
ianthomas_uk3: 2132647-nodesearch-settings-test-3.patch queued for re-testing.
Comment #6
jhodgdonWe don't normally like to see commented-out code, especially not such large stretches of it. I think that the code that adds the comments to the node and views the node can be left there -- what harm would it do to have it there? This test presumably used to pass without commenting out all that stuff -- let's just leave it as much like it was as possible, and just make the changes that will use the UI rather than variable_set(). OK?
Comment #7
ianthomas_ukIt's just unnecessary work for the test script, as the nodes created aren't used in the test.
The test worked before because views and comments were in the array before the commented out lines, and then removed before running the tests.
I'll go back to the old way of doing it though if that's the standard.
Comment #8
jhodgdonPersonally, I think that one line with a @todo saying "Remove this line when views and comments ranking are working" is a lot easier to deal with than 30 lines of commented-out code. Plus, this patch is a lot easier to review if the only thing it changes is to use the UI rather than the variable_set or config or whatever.
Comment #9
ianthomas_ukOK, here's a patch without that refactoring.
There are two identical
foreach ($node_ranks as $node_rank) {
lines in the function which makes the diff a bit confusing, so I've created a second version with the first foreach commented out, which should be easier to review. The code is identical, apart from the commented foreach, as shown by the interdiff.Comment #10
jhodgdonThanks! I like this version a lot better.
One thing: we don't ever want to use t() in test assertion messages. If you need to inject variables, you can use simple string concatentation, or format_string().
So this use of t() is correct, because it is asserting that some particular translated text appears in the UI:
But this one is for a message and needs to be removed:
Also, a nitpick: prioritize is spelled with a Z in Drupal-standard US English. :)
Other than those small problems, this patch looks good.
Comment #11
ianthomas_ukThanks for the review. Here's an updated patch with those corrections.
Comment #12
jhodgdonGreat!
Sorry, I missed this in the last review -- a small coding standards issue: we want a space around . for string concat operator:
should be
There are other spots as well with this same problem. Quite a few, actually.
Thanks!
Comment #13
ianthomas_ukThis patch has more spaces, I've also added a full stop at the end of the messages. I clicked the wrong button so the interdiff is actually a diff of the patches, but in this case that's probably slightly easier to read anyway.
Comment #14
ianthomas_ukComment #16
ianthomas_uk13: 2132647-nodesearch-settings-test-13.patch queued for re-testing.
Comment #17
jhodgdonThanks! This patch looks like a good update of the node rankings test, so that we have a test that uses the UI rather than just the config/variables. Let's get it in.
Comment #18
Xano13: 2132647-nodesearch-settings-test-13.patch queued for re-testing.
Comment #19
webchickYay tests! :)
Committed and pushed to 8.x. Thanks!