Skip to content

Add unit tests for console classes#20782

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

Add unit tests for console classes#20782
WarLikeLaux wants to merge 2 commits intoyiisoft:masterfrom
WarLikeLaux:add-BaseConsole-tests

Conversation

@WarLikeLaux
Copy link
Contributor

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues

What does this PR do?

Adds tests for BaseConsole, ExitCode and console Markdown - covers progress bar, ANSI formatting, cursor movement, screen size, wrapText, multi-byte string handling.

Coverage

File Tests Lines Methods MSI
BaseConsole.php 31 → 53 237/352 (67%) → 340/352 (97%) 33/54 → 53/54 76% (150/196)
ExitCode.php 2 1/1 (100%) 1/1 100% (3/3)
console/Markdown.php 5 5/6 (83%) 5/6 65% (17/26)

12 uncovered lines in BaseConsole are OS-dependent branches in getScreenSize (Windows, macOS stty, tput/ENV fallbacks), streamSupportsAnsiColors (Windows branch) and stdin() (blocks on STDIN read). 1 uncovered line in console/Markdown is renderStrike() which has a pre-existing bug (passes array to Console::ansiFormat).

Escaped mutants (all equivalent)

BaseConsole.php (46): PublicVisibility - L246, always equivalent. CastString x3 - L333/372/374, input is always string. LessThanOrEqualTo/LogicalOr/ReturnRemoval - L368-369, early return produces same empty result via loop. Remaining 38 mutants in getScreenSize (L687-728) and streamSupportsAnsiColors (L659-661) - platform-dependent code, single OS can only exercise one branch.

console/Markdown.php (9): ArrayItemRemoval x4 - ANSI format codes, tests strip formatting before assertion. Concat/ConcatOperandRemoval x4 - newline separators in rendered output. UnwrapRtrim - L65, trailing whitespace not asserted.

Changelog not required, because no source files changed.

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.87%. Comparing base (379b296) to head (2638e97).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20782      +/-   ##
============================================
+ Coverage     78.56%   78.87%   +0.30%     
  Complexity    11568    11568              
============================================
  Files           376      376              
  Lines         30750    30750              
============================================
+ Hits          24160    24255      +95     
+ Misses         6590     6495      -95     

☔ 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