Skip to content

Test uncovered code paths to reach 100% line coverage - #298

Open
WarLikeLaux wants to merge 4 commits into
yiisoft:masterfrom
WarLikeLaux:add-coverage-tests
Open

Test uncovered code paths to reach 100% line coverage#298
WarLikeLaux wants to merge 4 commits into
yiisoft:masterfrom
WarLikeLaux:add-coverage-tests

Conversation

@WarLikeLaux

@WarLikeLauxWarLikeLaux commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
QA
Is bugfix?
New feature?
Tests added?✔️
Tests pass?✔️
Breaks BC?
Fixed issues

What does this PR do?

Adds tests for previously uncovered code paths and removes the unreachable defensive throw branches in the middleware factories, bringing src coverage to 100%.

Per review: instead of marking those branches with @codeCoverageIgnore, the cause is removed. MiddlewareFactory::create() already returns T, so the instanceof checks in ConsumeMiddlewareFactory, FailureMiddlewareFactory and PushMiddlewareFactory were redundant and dropped. The final throw in create() is gone too: string/array are now handled separately from the callable branch, so every path is reachable and typed. Behavior is unchanged - only dead code is removed.

Summary by CodeRabbit

  • Tests

    • Added test coverage for command execution with negative pause values, queue decorator middleware methods, envelope metadata handling, and worker message processing.
    • Added validation tests for middleware factory invalid definitions and queue configuration errors.
  • Chores

    • Improved static analysis coverage with directives for unreachable code paths in middleware factories.

@WarLikeLaux

Copy link
Copy Markdown
ContributorAuthor

@coderabbitai full review

@coderabbitai

coderabbitaiBot commented Jun 5, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@codecov

codecovBot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (7bcbc2c) to head (88dfcb3).
⚠️ Report is 19 commits behind head on master.

Files with missing linesPatch %Lines
src/Middleware/MiddlewareFactory.php0.00%6 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## master #298 +/- ##
========================================
Coverage 0.00% 0.00% + Complexity 330 328 -2 
========================================
Files 49 49 Lines 910 903 -7 ========================================
+ Misses 910 903 -7 

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai

coderabbitaiBot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request adds code coverage annotations to middleware factories and expands test coverage across message handling, envelopes, failure validation, and queue configuration scenarios. The middleware factory changes mark unreachable exception paths for static analysis while excluding them from code coverage metrics. The test additions validate edge cases in message ID logging, envelope metadata, validation logic, and command behavior.

Changes

Code Quality and Test Coverage

Layer / File(s)Summary
Middleware Factory Code Coverage Annotations
src/Middleware/Consume/ConsumeMiddlewareFactory.php, src/Middleware/FailureHandling/FailureMiddlewareFactory.php, src/Middleware/MiddlewareFactory.php, src/Middleware/Push/PushMiddlewareFactory.php
Exception throw sites for non-conforming middleware results are wrapped with @codeCoverageIgnoreStart/End directives and marked unreachable at runtime, while preserved for static analyzers.
Message Processing and Envelope Metadata Tests
tests/Unit/WorkerTest.php, tests/Unit/Message/EnvelopeTest.php
New tests verify that Worker::process() logs message IDs for IdEnvelope instances and fails with RuntimeException for empty message types; DummyEnvelope::withMetadata() preserves metadata correctly.
Failure Handling and Validation Tests
tests/Unit/Middleware/FailureHandling/FailureEnvelopeTest.php, tests/Unit/Middleware/FailureHandling/Implementation/SendAgainMiddlewareTest.php
New tests verify that FailureEnvelope::getFailureMetadata() returns the failure metadata, and that SendAgainMiddleware constructor rejects non-positive maxAttempts values with appropriate exception messages.
Queue and Configuration Edge Case Tests
tests/Unit/Command/ListenAllCommandTest.php, tests/Unit/Debug/QueueDecoratorTest.php, tests/Unit/Middleware/Push/MiddlewareFactoryTest.php, tests/Unit/Provider/QueueFactoryProviderTest.php
New tests validate that QueueDecorator middleware methods return new decorator instances, QueueFactoryProvider throws on invalid definitions at get() time, PushMiddlewareFactory rejects non-callable scalars, and ListenAllCommand exits cleanly with negative pause values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 The factories now whisper to analyzers true,
Marking unreachable paths with coverage clue.
Tests bloom like carrots in the garden wide,
Edge cases and metadata, validated with pride!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 15.38% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title 'Test uncovered code paths to reach 100% line coverage' directly and clearly summarizes the main objective of the pull request, which is to add tests for previously untested code paths to achieve full coverage.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

Comment threadsrc/Middleware/Consume/ConsumeMiddlewareFactory.php Outdated
Comment threadsrc/Middleware/FailureHandling/FailureMiddlewareFactory.php Outdated
Comment threadsrc/Middleware/MiddlewareFactory.php Outdated
Comment threadsrc/Middleware/Push/PushMiddlewareFactory.php Outdated
@WarLikeLaux
WarLikeLaux requested a review from vjikJune 8, 2026 02:30
Sign up for freeto 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.

2 participants

@WarLikeLaux@vjik