tests: add PHPUnit tests for Free/Pro template path resolution#260
Merged
tests: add PHPUnit tests for Free/Pro template path resolution#260
Conversation
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.
Summary
Adds comprehensive PHPUnit tests verifying template path resolution works correctly for both Free and Pro plugin scenarios.
This prevents regressions like the critical bug where Quick View / Quick Frame templates failed to load when the Pro plugin was installed due to incorrect template path initialization.
Problem
When the Pro plugin was active, templates from
pro_plugin_path/templates/(e.g. popup/quick-view-data) were not being found by the template loader. This caused Quick View to stop working entirely. The root cause was related to path initialization and theis_allowed_template_path()security guard.Test Coverage
The new test class
Test_Class_Templates_Path(17 tests, ~575 lines) covers:Free Plugin Only
plugin_path/templates/find_template_styles()resolves CSS from the free pluginPro Plugin Active
pro_plugin_path/templates/Security (is_allowed_template_path)
CSS Resolution
find_template_styles()finds Pro CSS filesCritical Regression Tests
Edge Cases
templates/directory is missingpro_plugin_pathpro_plugin_pathconstruction has correct trailing slashHow It Works
Tests simulate the Pro plugin by creating a temporary directory structure with template files, and setting
visual_portfolio()->pro_plugin_pathto point at it. This exercises the exact same code paths used in production without requiring the actual Pro plugin to be installed.Test Results
All 64 tests pass (including 17 new ones), 164 assertions total.