Skip to content

fix(tests): Raise Code Coverage 100%.#8

Merged
terabytesoftw merged 1 commit intomainfrom
fix_mini_2
Feb 25, 2026
Merged

fix(tests): Raise Code Coverage 100%.#8
terabytesoftw merged 1 commit intomainfrom
fix_mini_2

Conversation

@terabytesoftw
Copy link
Copy Markdown
Contributor

Pull Request

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d01d4da and f7784d5.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/WordCaseConverter.php
  • tests/Support/MockerExtension.php
  • tests/WordCaseConverterTest.php
💤 Files with no reviewable changes (1)
  • src/WordCaseConverter.php
📜 Recent review details
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: terabytesoftw
Repo: php-forge/helper PR: 6
File: infection.json5:1-12
Timestamp: 2026-02-25T09:00:34.909Z
Learning: In the php-forge/helper project, mutation testing requires 100% mutation score (both minMsi and minCoveredMsi) as enforced by CI.
Learnt from: terabytesoftw
Repo: php-forge/foxy PR: 115
File: tests/Fallback/AssetFallbackTest.php:158-189
Timestamp: 2026-01-23T11:22:07.261Z
Learning: User terabytesoftw prefers not to use aliases when importing classes in PHP. They are comfortable with either fully-qualified class names or direct imports without aliases.
Learnt from: terabytesoftw
Repo: php-forge/support PR: 12
File: src/TestSupport.php:0-0
Timestamp: 2025-08-18T20:13:33.518Z
Learning: User terabytesoftw prefers clean trait-based designs over maintaining backward compatibility wrappers when refactoring utility classes in the php-forge/support project.
Learnt from: terabytesoftw
Repo: php-forge/actions PR: 65
File: .github/workflows/composer-require-checker.yml:80-83
Timestamp: 2025-09-28T15:12:48.345Z
Learning: The user terabytesoftw prefers using floating tags like v1 for third-party actions in GitHub workflows instead of pinning to specific commit SHAs, even when it's a security best practice to pin to immutable commits.
📚 Learning: 2026-01-22T11:42:40.861Z
Learnt from: terabytesoftw
Repo: php-forge/foxy PR: 111
File: tests/Fallback/AssetFallbackTest.php:98-98
Timestamp: 2026-01-22T11:42:40.861Z
Learning: When using xepozz/internal-mocker in PHP tests, the namespaced wrapper generated by the library records and compares function arguments including their default parameters. For example, a call to file_get_contents($path) is seen by the wrapper as file_get_contents($path, false, null, 0, null) with all defaults filled in. Therefore, MockerState::addCondition() must specify all parameters with their default values to properly match the mocked calls.

Applied to files:

  • tests/Support/MockerExtension.php
  • tests/WordCaseConverterTest.php
🧬 Code graph analysis (1)
tests/WordCaseConverterTest.php (1)
src/WordCaseConverter.php (2)
  • WordCaseConverter (20-117)
  • toTitleWords (88-116)
🪛 PHPMD (2.15.0)
tests/WordCaseConverterTest.php

[error] 81-86: Avoid using static access to class '\Xepozz\InternalMocker\MockerState' in method 'testToTitleWordsFallsBackWhenPregSplitFails'. (undefined)

(StaticAccess)


[error] 90-90: Avoid using static access to class '\PHPForge\Helper\WordCaseConverter' in method 'testToTitleWordsFallsBackWhenPregSplitFails'. (undefined)

(StaticAccess)

🔇 Additional comments (4)
CHANGELOG.md (1)

6-6: Changelog entry looks accurate and release-ready.

The new 0.2.0 bugfix note is clear and consistent with the section format.

tests/Support/MockerExtension.php (1)

66-69: preg_split mock registration is correctly wired.

Good addition to the mock list; this enables the new fallback-path unit test to control preg_split() behavior.

tests/WordCaseConverterTest.php (2)

21-21: Coverage docblock update is aligned with the new test scenario.

This documentation change accurately reflects the added fallback case.


79-93: Fallback test is correctly implemented and robust for internal-mocker matching.

The mocked preg_split() condition and expected ucfirst() fallback output are consistent with WordCaseConverter::toTitleWords() behavior.

Based on learnings: “When using xepozz/internal-mocker... MockerState::addCondition() must specify all parameters with their default values to properly match the mocked calls.”


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved code coverage to 100%.
  • Tests

    • Added test coverage for edge case handling and fallback behavior in word conversion functionality.

Walkthrough

The pull request removes the explicit preg_split import statement from WordCaseConverter while adding a mock for preg_split in test infrastructure and a new test case that validates fallback behavior when preg_split fails. A changelog entry for version 0.2.0 documents a code coverage fix.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added changelog entry for version 0.2.0 documenting "Raise Code Coverage 100%" bug fix.
Source Code
src/WordCaseConverter.php
Removed explicit preg_split import statement, creating dependency on implicit global namespace resolution in toTitleWords method.
Test Infrastructure
tests/Support/MockerExtension.php
Extended mock function configuration to include preg_split alongside existing function mocks.
Unit Tests
tests/WordCaseConverterTest.php
Added test method testToTitleWordsFallsBackWhenPregSplitFails() to verify fallback behavior when preg_split returns false.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A split removed, yet mocked with care,
When functions fail, we've fallback there—
With ucfirst as safety net,
Code coverage rises—no regrets!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(tests): Raise Code Coverage 100%' accurately reflects the main objective of the PR, which is to improve test coverage by adding new test cases and fixing related code issues.
Description check ✅ Passed The description relates to the changeset by confirming this is a bugfix that does not introduce new features or break backward compatibility, which aligns with the changes made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_mini_2

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.

@terabytesoftw
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@terabytesoftw terabytesoftw added the bug Something isn't working label Feb 25, 2026
@terabytesoftw terabytesoftw merged commit 3510598 into main Feb 25, 2026
49 checks passed
@terabytesoftw terabytesoftw deleted the fix_mini_2 branch February 25, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant