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
CommentFileSizeAuthor
#1 aet-add-some-tests-2476275-1.patch8.95 KBdman

Comments

dman’s picture

StatusFileSize
new8.95 KB

Patch submitted by the Drush iq-submit command.

colan’s picture

Version: 7.x-1.x-dev » 2.x-dev
Category: Feature request » Task
Status: Active » Needs work

Let'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.

  • colan committed 0b46d99 on 2.x authored by dman
    Issue #2476275 by dman: Added D7-style tests, to be converted to PHPUnit...
colan’s picture

Thanks for git am-able patch, but I couldn't use it because the info files are now different.

  • colan committed 2e46553 on 2.x
    Issue #2476275 by colan: Renamed test file for PHPUnit.
    
  • colan committed 5f00a6d on 2.x
    Issue #2476275 by colan: Updated test class metadata.
    
  • colan committed f22ca4c on 2.x
    Issue #2476275 by colan: Made the test class a descendent of the proper...
  • colan committed f461d41 on 2.x
    Issue #2476275 by colan: Dropped "Case" from the class name.
    
colan’s picture

The 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.

  • colan committed e59d1cb on 2.x
    Issue #2476275 by colan: First round at updating test methods.
    

  • colan committed f7bf122 on 2.x
    Issue #2476275 by colan: Got tests to fail without other errors.
    

  • colan committed fd6fe75 on 2.x
    Issue #2476275 by colan: Added missing `composer.json` to include `...

  • colan committed 0a89fd4 on 2.x
    Issue #2476275 by colan: Replaced deprecated code.
    
  • colan committed 89a83db on 2.x
    Issue #2476275 by colan: Set a testing theme as per https://www.drupal....
  • colan committed a2a0d6b on 2.x
    Issue #2476275 by colan: Commented out failing assertions to get clean...
  • colan committed a43cf20 on 2.x
    Issue #2476275 by colan: Removed unused `use` statement.
    

  • 0d25fda committed on 2.x
    Issue #2476275 by colan: Updated an assertion from D7 and uncommented...
colan’s picture

Status: Needs work » Fixed

This 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.

Status: Fixed » Closed (fixed)

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