-
-
Notifications
You must be signed in to change notification settings - Fork 0
test: Verify protected methods remain accessible to subclasses in NestedSetsBehavior
.
#31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…stedSetsBehavior`.
WalkthroughThis change introduces new test coverage and supporting test infrastructure to verify that the protected method Changes
Sequence Diagram(s)sequenceDiagram
participant Test as NestedSetsBehaviorTest
participant Model as ExtendableMultipleTree
participant Behavior as ExtendableNestedSetsBehavior
Test->>Model: Create instance
Model->>Behavior: Attach behavior
Test->>Behavior: Call exposedApplyTreeAttributeCondition(&condition)
Behavior->>Behavior: Set calledMethods['applyTreeAttributeCondition']
Behavior->>Behavior: Call parent::applyTreeAttributeCondition(&condition)
Test->>Behavior: Check wasMethodCalled('applyTreeAttributeCondition')
Test->>Behavior: Assert condition modified
Possibly related PRs
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 phpcs (3.7.2)tests/NestedSetsBehaviorTest.phpWarning: PHP Startup: Invalid date.timezone value 'UTC', using 'UTC' instead in Unknown on line 0 Fatal error: Uncaught Error: Class "Phar" not found in /usr/local/bin/phpcs:3 tests/phpstan-config.phpWarning: PHP Startup: Invalid date.timezone value 'UTC', using 'UTC' instead in Unknown on line 0 Fatal error: Uncaught Error: Class "Phar" not found in /usr/local/bin/phpcs:3 tests/support/model/ExtendableMultipleTreeQuery.phpWarning: PHP Startup: Invalid date.timezone value 'UTC', using 'UTC' instead in Unknown on line 0 Fatal error: Uncaught Error: Class "Phar" not found in /usr/local/bin/phpcs:3
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings
🧬 Code Graph Analysis (3)tests/phpstan-config.php (2)
tests/support/model/ExtendableMultipleTree.php (2)
tests/support/model/ExtendableMultipleTreeQuery.php (2)
🔇 Additional comments (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 90 90
===========================================
Files 2 2
Lines 469 469
===========================================
Hits 469 469 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for testing subclass access to protected methods in the nested sets behavior by introducing stub and extendable classes, updating PHPStan config, and adding a new test.
- Introduced
ExtendableNestedSetsBehavior
stub that exposes protected methods for tracking calls. - Added
ExtendableMultipleTree
model andExtendableMultipleTreeQuery
to wire in the stub behavior. - Updated
phpstan-config.php
to recognize the new model and behavior, and added a test verifying subclass access toapplyTreeAttributeCondition
.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/support/stub/ExtendableNestedSetsBehavior.php | Stub behavior exposing protected methods for test instrumentation |
tests/support/model/ExtendableMultipleTreeQuery.php | Custom ActiveQuery class attaching NestedSetsQueryBehavior |
tests/support/model/ExtendableMultipleTree.php | ActiveRecord model using the stub behavior with treeAttribute |
tests/phpstan-config.php | Registered ExtendableMultipleTree with NestedSetsBehavior |
tests/NestedSetsBehaviorTest.php | Added test to verify protected method access in subclass |
Comments suppressed due to low confidence (1)
tests/NestedSetsBehaviorTest.php:2055
- [nitpick] Consider adding tests for the other exposed protected methods (e.g., beforeInsertNode, deleteWithChildrenInternal, moveNode, etc.) to ensure full coverage that all protected methods remain accessible to subclasses.
public function testProtectedApplyTreeAttributeConditionRemainAccessibleToSubclasses(): void
Summary by CodeRabbit
New Features
Tests
Chores