-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Raise code coverage 100%. #11
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11 +/- ##
=============================================
+ Coverage 97.59% 100.00% +2.40%
Complexity 82 82
=============================================
Files 2 2
Lines 457 457
=============================================
+ Hits 446 457 +11
+ Misses 11 0 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
WalkthroughThis update introduces new test cases to the Changes
Sequence Diagram(s)sequenceDiagram
participant Test as NestedSetsBehaviorTest
participant Model as Tree/MultipleTree
participant Query as TreeQuery/MultipleTreeQuery
participant DB as Database
Test->>Model: call deleteWithChildren()
Model->>DB: begin transaction (if transactional)
Model->>Model: beforeDelete()
alt beforeDelete returns false
Model-->>Test: return false
else beforeDelete passes
Model->>DB: delete node and children
Model->>DB: update tree structure
Model-->>Test: return affected rows
end
Note over Test,Model: If exception during delete, propagate exception
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/support/model/MultipleTree.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/MultipleTreeQuery.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🧬 Code Graph Analysis (4)tests/support/model/TreeQuery.php (1)
tests/support/model/MultipleTreeQuery.php (1)
tests/support/model/Tree.php (1)
tests/support/model/MultipleTree.php (2)
🪛 PHPMD (2.15.0)tests/NestedSetsBehaviorTest.php1473-1473: Avoid using static access to class '\yii2\extensions\nestedsets\tests\support\model\Tree' in method 'testReturnAffectedRowsAndUpdateTreeAfterDeleteWithChildrenWhenManualTransactionIsUsed'. (Clean Code Rules) (StaticAccess) 1517-1517: Avoid using static access to class '\yii2\extensions\nestedsets\tests\support\model\Tree' in method 'testReturnAffectedRowsAndUpdateTreeAfterDeleteWithChildrenWhenManualTransactionIsUsed'. (Clean Code Rules) (StaticAccess) 1521-1521: Avoid using static access to class '\yii2\extensions\nestedsets\tests\support\model\Tree' in method 'testReturnAffectedRowsAndUpdateTreeAfterDeleteWithChildrenWhenManualTransactionIsUsed'. (Clean Code Rules) (StaticAccess) 1525-1525: Avoid using static access to class '\yii2\extensions\nestedsets\tests\support\model\Tree' in method 'testReturnAffectedRowsAndUpdateTreeAfterDeleteWithChildrenWhenManualTransactionIsUsed'. (Clean Code Rules) (StaticAccess) 1529-1529: Avoid using static access to class '\yii2\extensions\nestedsets\tests\support\model\Tree' in method 'testReturnAffectedRowsAndUpdateTreeAfterDeleteWithChildrenWhenManualTransactionIsUsed'. (Clean Code Rules) (StaticAccess) ⏰ Context from checks skipped due to timeout of 90000ms (9)
🔇 Additional comments (13)
✨ 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 (
|
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 refactors test support models for improved type safety and extends test coverage to cover deletion and root-creation edge cases.
- Added explicit constructors to
TreeQuery
andMultipleTreeQuery
for PHPStan generics support - Made
Tree
andMultipleTree
non-final
, updatedfind()
to usestatic::class
, and addedisTransactional()
override - Introduced new tests in
NestedSetsBehaviorTest
to verify delete-with-children behavior under manual transactions, exceptions, and missing primary keys
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/support/model/TreeQuery.php | Added __construct with PHPStan param annotations |
tests/support/model/Tree.php | Removed final , added isTransactional() , updated find() |
tests/support/model/MultipleTreeQuery.php | Added __construct with PHPStan param annotations |
tests/support/model/MultipleTree.php | Removed final , updated find() |
tests/NestedSetsBehaviorTest.php | Added tests for deletion with children, exception handling, root creation without PK |
Comments suppressed due to low confidence (2)
tests/support/model/TreeQuery.php:17
- Add a class-level
@template T of ActiveRecord
docblock above the class declaration so PHPStan can correctly resolve the genericT
used in the method annotations.
/**
tests/support/model/MultipleTreeQuery.php:17
- Add a class-level
@template T of ActiveRecord
docblock above the class declaration so PHPStan can correctly resolve the genericT
used in the method annotations.
/**
Summary by CodeRabbit