PageTypesServiceTest.test05: assert allowedChildTypes membership, not struct iteration order - #1804
Open
alexskinner wants to merge 1 commit into
Open
Conversation
… struct iteration order The casestudy page type has no allowedChildPageTypes, so it defaults to '*', which PageTypesService expands to listSiteTreePageTypes().toList() — i.e. the iteration order of a plain registered-page-types struct. That order is an engine implementation detail (Lucee's default struct iterates in Java HashMap hash-bucket order; engines with insertion-ordered default structs return the same members in a different order), so asserting the exact ordered string couples the test to the host engine rather than to Preside's behaviour. Sort both sides before comparing so the test verifies membership, consistent with test02 in the same file (which already sorts). The set of allowed child types is unchanged; only the incidental order is normalised.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PageTypesServiceTest.test05asserts the exact ordered string returned bygetAllowedChildTypes():That value isn't a meaningful ordering — it's the iteration order of a plain struct. The
casestudypage type declares noallowedChildPageTypes, so it defaults to*, andPageTypesService._calculateManagedPageTypes()expands*tolistSiteTreePageTypes().toList(), which is justfor( id in registeredPageTypes )over a default{}struct.That iteration order is an engine implementation detail:
{}is backed by a JavaHashMap, iterating in hash-bucket order — the source ofcasestudy,blog,event,....So the test currently passes/fails purely on the host's default-struct ordering, even when the service is behaving correctly — the set of allowed child types is identical (
{blog, casestudy, event, page, some_page_type, teammember}), only the order differs.Change
Sort both sides before comparing, so the assertion checks membership rather than incidental order — consistent with
test02in the same file, which already doesids.sort( "textnocase" ):super.assertEquals( ListSort( "casestudy,blog,event,some_page_type,page,teammember", "textnocase" ) , ListSort( pageTypeBean.getAllowedChildTypes(), "textnocase" ) );The test still verifies that a
*allowed-children type resolves to every site-tree page type; it's just decoupled from an unspecified struct iteration order.How it surfaced
Running the Preside test suite on an alternative CFML engine whose default struct is insertion-ordered.
test05is the only order-coupled assertion of this kind —test02/test12/test13already normalise order and pass on both.