Repository navigation
Tests: Add test cases for wp_find_hierarchy_loop() - #8091
Sukhendu2002 wants to merge 2 commits into
Conversation
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟡 Changes recommended
The six new tests use the wrong PHPUnit group, so they will be skipped when running with --group functions; the annotation should be changed to @group functions.
1 open issue
What changed in this PR
Adds PHPUnit coverage for wp_find_hierarchy_loop() as part of WordPress Core’s function tests, addressing Trac ticket #59901.
Changes:
- Adds six tests covering basic cycles, null-parent handling, self-references, and acyclic hierarchies.
- Checks detection of a cycle reached after traversing multiple hierarchy levels.
| File | Description |
|---|---|
tests/phpunit/tests/functions/wpFindHierarchyLoop.php |
Adds hierarchy-loop detection tests and expected-result assertions. |
Review effort: Balanced
lancewillett
left a comment
There was a problem hiding this comment.
The affected classes pass locally in single-site and multisite. Before approval, please fix @group Functions.php to @group functions, as Copilot noted; the current annotation omits these cases from the normal functions group. Optional: collapse the duplicate self-loop and terminating-chain scenarios, retaining the four distinct outcomes.
AI review · gpt-6
|
Refreshed against trunk in f9a7491, preserving the two tests already landed and retaining only two distinct additions. Fixed the All four cases pass in randomized single-site and multisite runs; PHPCS passes. Controlled mutations confirmed each new case catches a different regression that the existing two do not: an incorrect no-loop result, or inclusion of a node outside the cycle. The mutations were removed after validation. Fresh CI remains pending. AI review · |
lancewillett
left a comment
There was a problem hiding this comment.
The refresh preserves the two landed cases and adds two distinct checks: a terminating hierarchy and a cycle reached through a node outside that cycle. The duplicate cases are gone.
All four cases pass locally in randomized single-site and multisite runs. Two controlled mutations each failed only the corresponding new case, confirming that these assertions add protection. PHPCS passes, and current-head CI finished with 75 successful checks and 13 skipped.
The Trac milestone still needs updating before the SVN commit.
AI review · gpt-6
…the loop. Verify that `wp_find_hierarchy_loop()` returns an empty array for a terminating chain and excludes a leading noncycle node from the returned cycle members. Preserve the existing loop cases and correct the `functions` group annotation. Developed in: #8091 Props sukhendu2002. See #59901. git-svn-id: https://develop.svn.wordpress.org/trunk@65179 602fd350-edb4-49c9-b593-d223f7449a82
…the loop. Verify that `wp_find_hierarchy_loop()` returns an empty array for a terminating chain and excludes a leading noncycle node from the returned cycle members. Preserve the existing loop cases and correct the `functions` group annotation. Developed in: WordPress/wordpress-develop#8091 Props sukhendu2002. See #59901. Built from https://develop.svn.wordpress.org/trunk@65179 git-svn-id: http://core.svn.wordpress.org/trunk@64328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #8091 landed in https://core.trac.wordpress.org/changeset/65179 |

Adds two cases for
wp_find_hierarchy_loop(): a terminating hierarchy returns no loop, and a cycle reached through a noncycle node returns only its members.Preserves the two tests already landed in [65146], removes duplicate self-loop and longer terminating-chain cases, and corrects the group annotation to
functions.Trac ticket: https://core.trac.wordpress.org/ticket/59901