fix(templates): make Services.php + its reset() wiring accessor-conditional (#16, #17) - #14
Merged
Merged
Conversation
…tional (#16, #17) - Services.php now ships only when at least one module registers a Services accessor. A zero-accessor build (e.g. --modules shortcode) no longer carries a dead class with nothing but set()/reset() over a permanently empty array. - Plugin_TestCase's `use Services;` import and `Services::reset()` call in tearDown() are gated on the same has_services flag, via the existing {{#if flag}} template engine. - Services_Test's generated accessor test now covers the default construction path (assertInstanceOf on a bare call, before any set()) in addition to the memoisation, set()-override, and reset()-clears-the-override paths already covered. - Update the CLI's own test suite to match: the "foundational classes" test no longer expects src/Services.php in a zero-module scaffold, and the test-isolation test (#14, #15) asserts the has_services split and the rewritten Services_Test body. Closes re-audit #3 items #16 and #17.
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.
Closes re-audit #3's #16 and #17.
What changed
src/Services.phpnow ships only when at least one selected module registers a Services accessor. A zero-accessor build (e.g.--modules shortcode) no longer carries a dead class with nothing butset()/reset()over a permanently empty array.has_servicesflag intemplateFlags(index.js), consumed bytemplates/tests/Unit/Plugin_TestCase.phpthrough the existing{{#if flag}}template engine — itsuse Services;import andServices::reset()call intearDown()are now gated the same way.Services_Testaccessor test (built inaddService()) now also asserts the default construction path (assertInstanceOfon a bareServices::x()call, before anyset()), in addition to the memoisation,set()-override, andreset()-clears-the-override paths already covered.Test suite
Updated
tests/generator.test.jsto match:src/Services.phpin a zero-module scaffold; asserts it's absent instead (fix(templates): nest the REST endpoint so 'schema' survives register_rest_route()'s upgrade step (C) #16).Plugin_TestCaseassertions between an accessor-bearing scaffold and a zero-accessor one, and checks the rewrittenServices_Testbody (default-construction assertion,'built once'/'set() overrides'/'reset() cleared the override'messages).Verification
npm test: 69/69 pass.--modules ""and--modules caching) generated directly via the CLI and inspected — output matches the design;php -lclean on every generated file in both.🤖 Generated with Claude Code