Skip to content

Make toReadableSize tests tolerant of CakePHP 5.4 SI unit default - #340

Merged
dereuromark merged 1 commit into
masterfrom
fix-readable-size-si-units
Aug 2, 2026
Merged

Make toReadableSize tests tolerant of CakePHP 5.4 SI unit default#340
dereuromark merged 1 commit into
masterfrom
fix-readable-size-si-units

Conversation

@dereuromark

@dereuromark dereuromark commented Aug 2, 2026

Copy link
Copy Markdown
Owner

CakePHP 5.4.0 changed Number::toReadableSize() to divide by 1000 and label the result KB/MB/GB/TB. The previous 1024-based behavior is still available, but only behind the new IEC units switch, which renders KiB/MiB/GiB/TiB.

That flipped NumberHelperTest::testToReadableSize red on every testsuite job (e.g. 1206 bytes now renders as 1,21 KB instead of 1,18 KB).

Since the plugin still supports cakephp/cakephp: ^5.1.1, the expectations cannot be hardcoded to either scheme. They now branch on whether the core exposes setUseIecUnits(), which is the 5.4 marker. A second case asserts the explicit IEC output and is skipped on older cores.

No src/ change - this is purely the core default shifting under the helper.

Summary by CodeRabbit

  • Tests
    • Updated readable-size test coverage for decimal and binary unit formats.
    • Added coverage for IEC units, with compatibility handling for versions that do not support them.

CakePHP 5.4 changed Number::toReadableSize() to divide by 1000 and label
KB/MB/GB/TB, moving the previous 1024-based behavior behind the new IEC
units switch (KiB/MiB/...). The plugin still supports cakephp/cakephp
^5.1.1, so the expectations now branch on whether the core exposes
setUseIecUnits(), and a separate case covers the explicit IEC output.
@dereuromark dereuromark added this to the 3.x (CakePHP 5.x) milestone Aug 2, 2026
@dereuromark dereuromark added the bug label Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ebb2c4a-e06e-40bb-b345-ef483daeaa2c

📥 Commits

Reviewing files that changed from the base of the PR and between 1063666 and 5a58498.

📒 Files selected for processing (1)
  • tests/TestCase/View/Helper/NumberHelperTest.php

📝 Walkthrough

Walkthrough

The readable-size tests now support CakePHP decimal-unit defaults, preserve binary expectations on older versions, and add conditional IEC-unit coverage for KiB and GiB output.

Changes

Readable-size test coverage

Layer / File(s) Summary
Readable-size assertions
tests/TestCase/View/Helper/NumberHelperTest.php
The existing test detects Number::setUseIecUnits support before selecting expected output. A new test skips unsupported versions and verifies IEC KiB and GiB output.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: updating toReadableSize tests for CakePHP 5.4 SI-unit defaults.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-readable-size-si-units

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.

@codecov-commenter

codecov-commenter commented Aug 2, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.65%. Comparing base (1063666) to head (5a58498).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #340      +/-   ##
============================================
- Coverage     80.67%   80.65%   -0.02%     
  Complexity     2162     2162              
============================================
  Files            85       85              
  Lines          5934     5934              
============================================
- Hits           4787     4786       -1     
- Misses         1147     1148       +1     

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

@dereuromark
dereuromark merged commit 6b3fcc0 into master Aug 2, 2026
17 checks passed
@dereuromark
dereuromark deleted the fix-readable-size-si-units branch August 2, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants