Feature/allow skipping caching #26
Merged
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.
Description of the Change
This pull request improves the logic for enabling or disabling the class loader cache in the module initialization process, making it more flexible and testable. The main change is the introduction of a new method that centralizes the decision for using the cache, along with updated documentation and comprehensive tests.
Class loader cache logic improvements:
should_use_cache()inModuleInitialization.phpto determine whether the class loader cache should be used, based on environment type and specific constants. This replaces the previous inline logic and allows for easier testing and extension.get_classes()method to use the newshould_use_cache()method, improving clarity and maintainability.Configurability and documentation:
Modules-and-Initialization.mdto describe how to disable class caching using the newTENUP_FRAMEWORK_DISABLE_CLASS_CACHEconstant, especially for hosts that do not support file-based caching.Testing enhancements:
ModuleInitializationTest.phpto cover all branches of the newshould_use_cache()logic, ensuring correct behavior under different environment conditions and constant definitions.Brain\Monkey\Functions\stubsutility in the test file to facilitate function stubbing for environment simulation.How to test the Change
Run the PHPUnit tests
Changelog Entry
Credits
Props @darylldoyle, @fabiankaegy, @dustinrue
Checklist:
I have added Critical Flows, Test Cases, and/or End-to-End Tests to cover my change.