Skip to content

Strengthen console controller tests#20792

Open
WarLikeLaux wants to merge 4 commits intoyiisoft:masterfrom
WarLikeLaux:strengthen-console-controller-tests
Open

Strengthen console controller tests#20792
WarLikeLaux wants to merge 4 commits intoyiisoft:masterfrom
WarLikeLaux:strengthen-console-controller-tests

Conversation

@WarLikeLaux
Copy link
Contributor

@WarLikeLaux WarLikeLaux commented Mar 10, 2026

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

What does this PR do?

Adds tests for console controllers (CacheController, FixtureController, HelpController, ServeController, MigrateController, BaseMigrateController) to cover previously untested code paths.

Coverage

File Tests Lines MSI
CacheController.php 27 81/106 (76%) → 94/94 (100%) 87% (99/113)
FixtureController.php 51 0/188 (0%) → 169/171 (99%) 60% (155/256)
HelpController.php 9 → 36 225/269 (84%) → 251/252 (100%) 69% (321/460)
ServeController.php 5 → 8 41/45 (91%) → 37/40 (93%) 69% (39/56)
BaseMigrateController.php +47 132/348 (38%) → 312/323 (97%) N/A
MigrateController.php +34 58/249 (23%) → 234/239 (98%) N/A

CacheController and FixtureController had existing tests that required MySQL. New test classes (CacheControllerSqliteTest, FixtureControllerSqliteTest) test the same code without MySQL dependency, making them runnable in all CI environments.

MigrateController/BaseMigrateController MSI unavailable due to pre-existing test failures (template PHPDoc mismatch in testGenerateMigration, MySQL driver in testRefreshMigration#1).

Uncovered lines:

  • FixtureController:159,235 - dead code (defensive checks after getFixturesConfig() which always throws before returning empty)
  • HelpController:496 - dead branch ($type === null after trim((string)$type))
  • ServeController:135-136 - isAddressTaken() true path (needs real open port); 141 - passthru() in runCommand()
  • BaseMigrateController:488,490 - YII_ENV_PROD constant branch; 681,683 - file_put_contents failure; 815-823,975,998 - methods overridden in MigrateController
  • MigrateController:313-314,328 - FK dropping / non-view error (SQLite doesn't support DROP FOREIGN KEY); 491-492 - dead code (ReflectionException never thrown, DI wraps it in InvalidConfigException)

Changelog not required, because no source files changed.

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.52%. Comparing base (279108f) to head (5ea60d7).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20792      +/-   ##
============================================
+ Coverage     78.68%   79.52%   +0.84%     
  Complexity    11566    11566              
============================================
  Files           376      376              
  Lines         30748    30748              
============================================
+ Hits          24194    24453     +259     
+ Misses         6554     6295     -259     

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

@WarLikeLaux WarLikeLaux marked this pull request as ready for review March 10, 2026 19:25
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