Skip to content

Add tests to kill escaped mutants (#529)#545

Open
dbuhonov wants to merge 68 commits intoyiisoft:masterfrom
dbuhonov:feature/529-mutant-part-1
Open

Add tests to kill escaped mutants (#529)#545
dbuhonov wants to merge 68 commits intoyiisoft:masterfrom
dbuhonov:feature/529-mutant-part-1

Conversation

@dbuhonov
Copy link
Copy Markdown

@dbuhonov dbuhonov commented Mar 13, 2026

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues part of #529

Covered Code MSI: 98%

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.87%. Comparing base (1dfe8f7) to head (6b0ea41).

Files with missing lines Patch % Lines
src/Event/Handler/SoftDelete.php 90.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              master     #545      +/-   ##
=============================================
- Coverage     100.00%   99.87%   -0.13%     
- Complexity       654      656       +2     
=============================================
  Files             43       43              
  Lines           1628     1612      -16     
=============================================
- Hits            1628     1610      -18     
- Misses             0        2       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbuhonov dbuhonov force-pushed the feature/529-mutant-part-1 branch from ec926d0 to 27f1743 Compare March 13, 2026 09:09
dbuhonov added 27 commits March 13, 2026 13:41
Copy link
Copy Markdown

Copilot AI left a 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/extends PHPUnit coverage across ActiveRecord, ActiveQuery, events, array access/arrayable behavior, and several internal helpers to improve mutation score (Issue #529) by exercising previously untested branches and edge-cases.

Changes:

  • Added many new tests around relation population/reset, upsert/link/unlink edge cases, event dispatching, and query/join/via behaviors.
  • Introduced multiple new test stub ActiveRecord/ActiveQuery classes to support targeted scenarios (deep via relations, composite PKs, overridden internals, etc.).
  • Updated Infection configuration with explicit mutator ignores for specific survivors.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Stubs/MagicActiveRecord/CategoryWithNameRelationArrayAccess.php New stub for ArrayAccess + magic relation name collision scenarios.
tests/Stubs/ActiveRecord/OrderWithCustomerProfileViaCustomerRelation.php New stub to exercise nested “via” relation dependency handling.
tests/Stubs/ActiveRecord/OrderItemWithDeepViaProfile.php New stub to cover deep via chain relation population.
tests/Stubs/ActiveRecord/OrderItemWithConstructor.php Docblock fix for stub class name.
tests/Stubs/ActiveRecord/EmployeeWithPrototypeDossierRelation.php New stub for prototype-cloned relation target and stricter PK checks.
tests/Stubs/ActiveRecord/CustomerWithUpdateInternalOverride.php New stub to test overridable updateInternal().
tests/Stubs/ActiveRecord/CustomerWithRefreshInternalOverride.php New stub to test overridable refreshInternal().
tests/Stubs/ActiveRecord/CustomerWithOverriddenRelationQuery.php New stub to test overridable relation query creation.
tests/Stubs/ActiveRecord/CustomerWithDeleteInternalOverride.php New stub to test overridable deleteInternal().
tests/Stubs/ActiveRecord/CustomerSetValueOnUpdateUpsert.php New stub for SetValueOnUpdate behavior during upsert.
tests/Stubs/ActiveRecord/CustomerEventsModel.php New stub enabling EventsTrait on Customer.
tests/Stubs/ActiveRecord/CompositePrimaryKeyDossier.php New stub for composite PK relation/linking scenarios.
tests/Stubs/ActiveQuery/SingleModelArrayActiveQuery.php New stub to ensure one() path doesn’t fall back to all().
tests/Stubs/ActiveQuery/OverriddenPrimaryTableNameActiveQuery.php New stub to cover overriding primary table resolution.
tests/Stubs/ActiveQuery/OverriddenCreateModelsActiveQuery.php New stub to cover overriding model creation from rows.
tests/Stubs/ActiveQuery/MissingLinkValuesActiveQuery.php New stub for missing link values during relation population.
tests/Stubs/ActiveQuery/CreateModelsExceptionOnEmptyRowsActiveQuery.php New stub ensuring empty populate doesn’t call createModels().
tests/Stubs/ActiveQuery/AlternativeActiveQuery.php New stub for alternate ActiveQuery implementation.
tests/RepositoryTraitTest.php Added coverage for find() behavior with null condition/params handling.
tests/MagicActiveRecordTest.php Added tests for save/update behavior and property accessor edge-cases.
tests/EventsTraitTest.php Expanded event dispatch/handler behavior coverage (after-events, soft delete, defaults, etc.).
tests/Driver/Pgsql/ActiveQueryTest.php Added PG-specific assertions for ModelRelationFilter conditions.
tests/ArrayableTraitTest.php Added extraFields() coverage.
tests/ArrayAccessTraitTest.php Expanded ArrayAccess tests for properties vs relations and magic properties.
tests/ActiveRecordTest.php Added extensive relation reset/dependency, PK error message, upsert/link/unlink/counters, override hooks tests.
tests/ActiveQueryTest.php Added extensive coverage for populate/dedup, joinWith validation, viaTable callable, relation population internals.
infection.json.dist Added explicit mutator ignore configuration for remaining survivors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/ActiveRecordTest.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithRefreshInternalOverride.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithOverriddenRelationQuery.php Outdated
dbuhonov and others added 2 commits March 20, 2026 00:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@samdark samdark requested review from Tigrov and vjik March 19, 2026 20:08
Comment thread tests/Driver/Pgsql/ActiveQueryTest.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithDeleteInternalOverride.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithOverriddenRelationQuery.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithRefreshInternalOverride.php Outdated
Comment thread tests/Stubs/ActiveRecord/CustomerWithUpdateInternalOverride.php Outdated
Comment thread tests/Stubs/ActiveRecord/EmployeeWithPrototypeDossierRelation.php
Comment thread CHANGELOG.md Outdated
@dbuhonov
Copy link
Copy Markdown
Author

Up review pls

Comment thread tests/ActiveRecordTest.php Outdated
Comment thread tests/ActiveRecordTest.php Outdated
Comment thread tests/ActiveRecordTest.php Outdated
Comment thread tests/ActiveRecordTest.php Outdated
Comment thread tests/ArrayAccessTraitTest.php
Comment thread tests/ActiveQueryTest.php Outdated
Comment thread tests/ActiveQueryTest.php Outdated
Comment thread tests/ActiveQueryTest.php Outdated
Comment thread tests/ActiveQueryTest.php Outdated
Comment thread tests/ActiveQueryTest.php Outdated
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b81e1bad-f7b2-49fb-9649-4958f05a124c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@Tigrov Tigrov May 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants