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.
We need test coverage over all tokens in core, not just on a few tokens to test replacement as we currently have in system.test. For example, lack of token coverage let this bug go uncovered by testing: #609090: Invalid call to node_get_types() in node.tokens.inc
I'm currently working on these tests.
Comment | File | Size | Author |
---|---|---|---|
#20 | 701818-token-tests-D7.patch | 45.74 KB | Dave Reid |
#18 | 701818-token-tests-D7.patch | 46.51 KB | Dave Reid |
#13 | 701818_token_tests.patch | 44.71 KB | mcarbone |
#9 | 701818_token_tests.patch | 44.82 KB | mcarbone |
#4 | 701818_token_tests.patch | 46.87 KB | mcarbone |
Comments
Comment #1
mcarbone CreditAttribution: mcarbone commentedAdding tag.
Comment #2
mcarbone CreditAttribution: mcarbone commentedAttached is a patch with tests for every Drupal core token. While writing the tests, I found quite a few various bugs involving token generation code, all of which are also fixed in this patch. Many of these bugs were found in the file token code, which was very outdated.
I'm setting this to 'needs review' since there's a bit to look like, although this patch will fail the testbot until #609118: node.tokens.inc: $node->body issues is resolved, and this patch is tweaked to reflect the fix.
Comment #4
mcarbone CreditAttribution: mcarbone commentedHurrah, I was able to get around waiting for #609118: node.tokens.inc: $node->body issues to be resolved by making sure to explicitly create a summary when creating the node, so these tests, if they get by the testbot, are ready to be reviewed for reals.
Comment #5
Dave ReidAwesome job getting test coverage!
Instead of building the large array of tokens strings to compare, can we run them as individual cases?
This way is going to be much easier to debug when something is going wrong. :)
Comment #6
mcarbone CreditAttribution: mcarbone commentedI borrowed that approach from the already existing testTokenReplacement test in system.test, so I assumed it was OK. But I guess since we now have so many more tests like this, it's worth fixing these new ones, and also the existing system ones. Will get to that soon.
Comment #7
Dave ReidWe should probably split out the comment:changed token into its own issues as well.
Comment #8
mcarbone CreditAttribution: mcarbone commentedWhy? There were like 15-20 bugs that I fixed when writing these tests, and the comment:changed one doesn't seem any worse to me than the fact that the file tokens were almost all broken. If you want, we can rename this issue to something like "Fix broken tokens and add tests."
Comment #9
mcarbone CreditAttribution: mcarbone commentedRe-wrote the tests to test each token individually as suggested in #5. I left the original tests in system.test alone because they aren't there to test individual tokens, and there is value there in testing them as bigger strings.
Comment #10
mcarbone CreditAttribution: mcarbone commentedRe-naming and requesting a re-test.
Comment #11
mcarbone CreditAttribution: mcarbone commented#9: 701818_token_tests.patch queued for re-testing.
Comment #13
mcarbone CreditAttribution: mcarbone commentedRe-rolled to keep up with HEAD.
Comment #14
webchickBumping to critical.
Comment #15
catchThe node body fix here isn't quite complete, see #609118: node.tokens.inc: $node->body issues which I've just marked as duplicate, but which needs the same fix copying over here. That should be applied to comment body too.
Comment #16
Dave Reid#13: 701818_token_tests.patch queued for re-testing.
Comment #17
catchNo way this applies since the other patch was just committed.
Comment #18
Dave ReidComment #19
catch$comment->body needs the same change as was made for $node->body in #609118: node.tokens.inc: $node->body issues, we can't guarantee that safe_value is always set.
Comment #20
Dave ReidComment #21
catchPatch looks good. All the actual bug fixes are very trivial - renaming variables etc., tests are consistent and there's loads of them, comment->body issue is properly fixed now.
Comment #22
webchickWell this is easily the most satisfying patch I've committed in a long time. Great work, Marco!
Committed to HEAD! :D