I was experimenting with some work-arounds to (what I see as) the problem of simple tokens being flagged as 'Recursion' too often.
In order to ensure I wasn't breaking existing behaviour, I have added a test suite that checks a number of expected behaviours.
I'll attach the test cases here.
Much of this could be done as unit tests also/instead, but WebTestCases are a bit more intuitive for what I'm looking at.
Run it as
drush test-run AETRecursionWebTestCase
or if you don't use drush
php scripts/run-tests.sh --verbose --class AETRecursionWebTestCase
Here are some of the relevant assertions it contains so far.
Pass Other aet.test 108 AETRecursionWebTestCase->testSingle
Content from the token pulling body data from the target was found in the
wrapper page when using token [aet:node:1:body]
Pass Other aet.test 109 AETRecursionWebTestCase->testSingle
Using token [aet:node:1:body] did not trigger a recursive token warning.
Pass Other aet.test 116 AETRecursionWebTestCase->testSingle
Using token [aet:node:1] did not trigger a recursive token warning.
Pass Other aet.test 117 AETRecursionWebTestCase->testSingle
Embedded nodes title was found when embedding token [aet:node:1]
Pass Other aet.test 118 AETRecursionWebTestCase->testSingle
Embedded nodes body was found when embedding token [aet:node:1]
Pass Other aet.test 125 AETRecursionWebTestCase->testSingle
Using token [aet:user:2] did not trigger a recursive token warning.
Pass Other aet.test 126 AETRecursionWebTestCase->testSingle
User history name was found when embedding token [aet:user:2]
Fail Other aet.test 156 AETRecursionWebTestCase->testSelfEm
Node was able to embed its own title using a token [aet:node:1:title].
Fail Other aet.test 157 AETRecursionWebTestCase->testSelfEm
Using token [aet:node:1:title] did not trigger a recursive token warning.
Pass Other aet.test 166 AETRecursionWebTestCase->testSelfEm
Recursive token use was accurately detected
Pass Other aet.test 167 AETRecursionWebTestCase->testSelfEm
Attempting to embed the body inside itself failed correctly when using token
[aet:node:1:body].
Pass Other aet.test 215 AETRecursionWebTestCase->testCyclic
Alpha node could embed the beta nodes title OK.
Pass Other aet.test 216 AETRecursionWebTestCase->testCyclic
Recursive token use was accurately detected when creating an embed loop
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | aet-add-some-tests-2476275-1.patch | 8.95 KB | dman |
Comments
Comment #1
dman commentedPatch submitted by the Drush iq-submit command.
Comment #2
colanLet's follow Converting SimpleTests to PHPUnit tests to get this working for Drupal 8+.
I enabled branch and commit testing. All okay so far except for some coding standards messages. A lot of these should disappear with #3162279: Refactor code to make it OO with small clean methods.
Comment #4
colanThanks for
git am-able patch, but I couldn't use it because the info files are now different.Comment #6
colanThe branch is failing now, which is good because it means the outdated test is running. We'll know we have things more or less working once it starts passing.
Comment #12
colanThis is basically working. We're still getting test failures, but that's because some of the assertions should in fact be failing. What's generally not working is embedding whole entities, but this can be fixed elsewhere.
See #3163125: Fix test failures for the follow-up.