Skip to content

Refactor migration class declaration and improve test assertions for migration controller.#20816

Merged
terabytesoftw merged 3 commits intoyiisoft:22.0from
terabytesoftw:fix-tests-1
Apr 11, 2026
Merged

Refactor migration class declaration and improve test assertions for migration controller.#20816
terabytesoftw merged 3 commits intoyiisoft:22.0from
terabytesoftw:fix-tests-1

Conversation

@terabytesoftw
Copy link
Copy Markdown
Member

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: 78b91d99-940f-4b8f-83b7-e478805d8ebb

📥 Commits

Reviewing files that changed from the base of the PR and between 48c6bf5 and 1ee69da.

📒 Files selected for processing (1)
  • tests/framework/console/controllers/MigrateControllerTest.php

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Fixed test flakiness by using fixed absolute timestamps in test data.
  • Tests

    • Replaced outdated assertion helpers with current assertion methods for compatibility.
    • Improved output suppression in migration tests to reliably discard console output.
  • Chores

    • Removed obsolete static analysis baseline suppressions.
    • Cleaned up generated migration template documentation.

Walkthrough

Test assertions were refactored to use correct PHPUnit method names, output buffering was updated in a migration controller test, phpstan baseline ignore entries were removed for those assertions, and time-based test data was changed to fixed absolute UTC timestamps.

Changes

Cohort / File(s) Summary
phpstan baseline
phpstan-baseline.neon
Removed two ignoreErrors entries related to tests/framework/console/controllers/MigrateControllerTest.php that suppressed undefined assertion and output-callback reports.
Console controller tests
tests/framework/console/controllers/MigrateControllerTest.php, tests/framework/console/controllers/MigrateControllerTestTrait.php
Replaced setOutputCallback(...) usage with native output buffering (ob_start() / ob_end_clean() in finally) in testCreateLongNamedMigration; replaced assertNotStringContainsString() with correct assertStringNotContainsString() in two test assertions.
Test templates & data
tests/data/console/migrate_create/default.php, tests/framework/web/CookieCollectionTest.php
Removed PHPDoc class comment from migration template; replaced relative time calculations in cookie tests with fixed UTC timestamps (2020-01-01, 2100-01-01) to avoid time-dependent failures.

Possibly related PRs

  • Update PHPStan baseline. #20803 — Adjusts phpstan baseline ignore rules including removals/changes for test files (related to phpstan ignore edits in this PR).

Poem

🐰 I hopped through tests with careful cheer,
Replaced mistakes that once were near.
I buffered output, fixed the time,
Cleaned the baseline, one less sign.
Now migrations, cookies, all align. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: removing PHPDoc from migration class declaration and updating test assertions to use corrected method names.
Description check ✅ Passed The description provides relevant context by identifying this as a bugfix that maintains backward compatibility, though minimal detail is given about the specific changes.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/framework/console/controllers/MigrateControllerTest.php`:
- Around line 451-457: The test assigns to $params[0] before $params is defined,
causing an undefined-variable notice; initialize $params as an array (e.g.,
$params = []) before assigning $params[0] so the call to
$controller->run('create', $params) receives a properly defined array; update
the MigrateControllerTest method containing the $params assignment accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

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

Review profile: ASSERTIVE

Plan: Pro

Run ID: c98ff07a-48f5-4b23-a88d-3f1e00deff49

📥 Commits

Reviewing files that changed from the base of the PR and between 2c9b4ac and 48c6bf5.

📒 Files selected for processing (5)
  • phpstan-baseline.neon
  • tests/data/console/migrate_create/default.php
  • tests/framework/console/controllers/MigrateControllerTest.php
  • tests/framework/console/controllers/MigrateControllerTestTrait.php
  • tests/framework/web/CookieCollectionTest.php
💤 Files with no reviewable changes (2)
  • tests/data/console/migrate_create/default.php
  • phpstan-baseline.neon

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.76%. Comparing base (2c9b4ac) to head (1ee69da).
⚠️ Report is 1 commits behind head on 22.0.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               22.0   #20816   +/-   ##
=========================================
  Coverage     82.76%   82.76%           
  Complexity    11311    11311           
=========================================
  Files           385      385           
  Lines         29802    29802           
=========================================
  Hits          24665    24665           
  Misses         5137     5137           

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

@terabytesoftw terabytesoftw merged commit dcffcde into yiisoft:22.0 Apr 11, 2026
40 checks passed
@terabytesoftw terabytesoftw deleted the fix-tests-1 branch April 11, 2026 16:56
@terabytesoftw terabytesoftw added 22 Yii 2.2 type:bug Bug labels Apr 11, 2026
@terabytesoftw terabytesoftw added this to the 22 milestone Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

22 Yii 2.2 type:bug Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant