[#3019] Fixed 'getProtectedValue()' reading the property from the reflection class instead of the object. - #3020
[#3019] Fixed 'getProtectedValue()' reading the property from the reflection class instead of the object.#3020AlexSkrypnyk wants to merge 7 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (18)
📒 Files selected for processing (2)
Included review availability: 0 reviews are currently available. Based on recent review activity, included reviews refill at 1 per hour. WalkthroughThe reflection helper now reads protected properties from the supplied object. A PHPUnit test suite covers instance, static, inherited, mixed-value, and missing-property cases. ChangesReflection access
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR corrects protected instance-property reads and adds regression coverage plus updated installer fixtures. No actionable merge-blocking risk remains beyond normal checks and review. Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
📖 Documentation preview for this pull request has been deployed to Netlify: https://6a8103c1ea98cb7affdc3d85--vortex-docs.netlify.app This preview is rebuilt on every commit and is not the production documentation site. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3020 +/- ##
==========================================
- Coverage 87.12% 86.71% -0.41%
==========================================
Files 101 94 -7
Lines 4917 4758 -159
Branches 47 3 -44
==========================================
- Hits 4284 4126 -158
+ Misses 633 632 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Code coverage (threshold: 90%) Per-class coverage |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Code coverage (threshold: 90%) Per-class coverage |
Closes #3019
Summary
ReflectionTrait::getProtectedValue()passed theReflectionClassbuilt from$object::classtoReflectionProperty::getValue()instead of the object being inspected, so every call against a non-static property raisedReflectionException: Given object is not an instance of the class this property was declared in. Static properties ignore that argument, which is why the defect stayed hidden. The trait ships to every consumer project atweb/modules/custom/<module>_base/tests/src/Traits/, andahoy update-vortexre-renders it, so a consumer's local fix was reverted on the next update.The method also had no test coverage anywhere in the repository, which is why the defect survived. Rather than shipping a test into every consumer site, the shipped test traits are now covered by a unit suite inside the
.vortex/harness, which never reaches consumer projects.Changes
Fix
web/modules/custom/ys_base/tests/src/Traits/ReflectionTrait.php:getProtectedValue()now calls$property->getValue($object)instead of$property->getValue($class). Its parameters gainedobject $object/string $propertytype hints so all three methods on the trait are consistently typed, and the@param $objectdescription was corrected from "Object to set the value on." to "Object to get the value from."Coverage for the shipped test traits
.vortex/tests/phpunit/Unit/ReflectionTraitTest.php: coversgetProtectedValue()(instance property across seven value types, reading from the specific instance passed in, static property, inherited property, unknown property),setProtectedValue(), andcallProtectedMethod()including its three error paths..vortex/tests/phpunit/Unit/ArrayTraitTest.php,AssertTraitTest.php,MockTraitTest.php: cover the remaining traits that can run outside a Drupal bootstrap.BrowserHtmlDebugTraitis not covered because it depends onDRUPAL_ROOTandcreateScreenshot()from Drupal's browser test base..vortex/tests/composer.json: mapsDrupal\Tests\ys_base\Traits\onto the template directory so the suite exercises the exact files consumers receive, and addstest-unitandtest-unit-coveragescripts..vortex/tests/phpunit.xml: adds aunittestsuite and narrowsdefaulttophpunit/Functionalso nothing runs twice. Coverage setsdisableCodeCoverageIgnorebecause the traits carry@codeCoverageIgnoreto keep them off a consumer site's own coverage figures..github/workflows/vortex-test-common.yml: runs the unit suite once, on batch 0 of the existingvortex-test-workflowjob, writing Cobertura output into the directory already uploaded to Codecov. The runner image ships pcov, so no coverage driver setup is needed;pcov.directoryis widened to the repository root because the traits sit outside the working directory.Current figures:
ReflectionTrait,ArrayTraitandAssertTraitat 100% of lines and methods;MockTraitat 86% of lines, since itsStubbranch cannot be reached now that PHPUnit 12 has removedTestCase::returnValue().Fixtures
.vortex/installer/tests/Fixtures/handler_process/**: regenerated withahoy update-snapshotsso every scenario's snapshot of the trait matches the fixed source, including thedocroot/-hosted Acquia scenarios and the renamed-module scenario.Before / After