Skip to content

Add unit tests for captcha classes#20787

Open
WarLikeLaux wants to merge 2 commits intoyiisoft:masterfrom
WarLikeLaux:add-captcha-tests
Open

Add unit tests for captcha classes#20787
WarLikeLaux wants to merge 2 commits intoyiisoft:masterfrom
WarLikeLaux:add-captcha-tests

Conversation

@WarLikeLaux
Copy link
Contributor

Q A
Is bugfix?
New feature?
Tests added? ✔️
Breaks BC?
Fixed issues

What does this PR do?

Adds unit tests for CaptchaAction, CaptchaAsset, and CaptchaValidator.

Coverage

File Tests Lines MSI
framework/captcha/CaptchaAction.php 37 98/125 (78%) 42% (101/240)
framework/captcha/CaptchaAsset.php 2 0/0 (100%) n/a
framework/captcha/CaptchaValidator.php 16 30/30 (100%) 76% (29/38)

Uncovered lines

  • framework/captcha/CaptchaAction.php:258 is the auto-detection branch in renderImage(). The tests pin imageLibrary to gd to keep image rendering deterministic across environments.
  • framework/captcha/CaptchaAction.php:263, 333-361 are the imagick branch. It is not covered because these tests do not require the imagick extension.
  • framework/captcha/CaptchaAction.php:320 is only reachable on PHP < 8.0, while the test run uses PHP 8+.

Changelog not required, because no source files changed.

@codecov
Copy link

codecov bot commented Mar 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.07%. Comparing base (068c5a4) to head (90004fd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20787      +/-   ##
============================================
+ Coverage     78.62%   79.07%   +0.44%     
  Complexity    11566    11566              
============================================
  Files           376      376              
  Lines         30748    30748              
============================================
+ Hits          24176    24314     +138     
+ Misses         6572     6434     -138     

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant