Skip to content

fix(upgrade): bring the 2.0 upgrade up to date with Flarum 2.0.0 - #58

Merged
imorland merged 1 commit into
3.xfrom
im/upgrade-2-0-stable-versions
Oct 11, 2026
Merged

imorland merged 1 commit into
3.xfrom
im/upgrade-2-0-stable-versions

Conversation

@imorland

Copy link
Copy Markdown
Member

Fixes: no issue.

Changes proposed in this pull request:
upgrade 2.0 still targeted the RC period and PHPUnit 11. It no longer sets minimum-stability: beta. It drops the workflows' php_versions input, so the reusable workflow's default (PHP 8.3–8.5) applies, instead of writing a matrix with 8.2. It requires flarum-webpack-config ^3.0.6 (the first to load an extension's code-split chunks from its own build) and webpack ^5.104.1, in both the upgrade and the scaffold. The package.json update now reaches both dependencies and devDependencies; only one of them was updated before.

The PHPUnit step now targets PHPUnit 12, which reads no doc-comment metadata:

  • every annotation with an attribute becomes one, on classes and methods;
  • @dataProvider Class::method and @depends Class::method become *External attributes (the provider used to be silently dropped);
  • assertions PHPUnit 10 renamed are renamed, and ->will($this->returnValue(…)) and its siblings become will*();
  • what was removed without a replacement gets a @TODO.

Reviewers should focus on:

  • The PHPUnit step's commit message changes, so an extension that ran the old step will run this one too. It is idempotent: a test runs it twice.
  • Removed TestCase methods with common names (setLocale(), iniSet(), at(), expect*()) are only flagged on $this/self/static, because Flarum tests call $translator->setLocale().
  • I ran the rewriter over all 180 PHPUnit 9 test files on framework's 1.x. Every output parses, all 840 @test and 46 @dataProvider annotations were converted, and no TODOs were needed.

Screenshot
N/A

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension? (N/A)
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation. (N/A)
  • Frontend changes: tests are green (run yarn test in js/). (yarn test: 221 tests, plus Prettier, ESLint and tsc.)
  • Frontend changes: tests have been added, or are not appropriate here. (31 new tests, written first and seen failing.)
  • Backend changes: tests are green (run composer test). (N/A)
  • Backend changes: tests have been added, or are not appropriate here. (N/A)
  • Where applicable, changes are suitable for all supported database drivers (MySQL, MariaDB, PostgreSQL, SQLite). (N/A)
  • Core developer confirmed locally this works as intended.
  • The description above is written by me and describes what this pull request actually does.

Required changes:

None.

- Stop setting minimum-stability: beta, now that 2.0 is stable.
- Drop the workflows' php_versions input, so the reusable workflow's
  default (the PHP versions Flarum 2.0 supports) applies.
- Require flarum-webpack-config ^3.0.6 and webpack ^5.104.1, in the
  upgrade and the scaffold, and update both dependencies and
  devDependencies.
- Bring tests to PHPUnit 12: annotations become attributes, renamed
  assertions are renamed, stub helpers become will*() calls, and what
  was removed without a replacement is flagged.
@imorland
imorland marked this pull request as ready for review October 11, 2026 11:17
@imorland
imorland merged commit 568deaf into 3.x Oct 11, 2026
3 checks passed
@imorland
imorland deleted the im/upgrade-2-0-stable-versions branch October 11, 2026 11:18
imorland added a commit that referenced this pull request Oct 11, 2026
The PHPUnit 12 rewrite in #58 wrote attributes in the order the
annotations were written, so a test with @dataProvider above @test got
#[DataProvider] above #[Test]. The original rewriter put #[Test] first,
as Flarum's own tests have it. Found by running both versions over the
1.x tests of 36 FoF extensions and core.
imorland added a commit that referenced this pull request Oct 11, 2026
…#60)

* feat(upgrade): give each model a factory, written from its migrations

Flarum 2.0 tests fill the columns a test leaves out from a model's
factory, when prepareDatabase() is given the model class rather than its
table.

- A new upgrade step writes a factory next to each of the extension's
  models, from what its migrations say about the model's table, and gives
  the model HasFactory. A factory the extension already has is kept.
- The PHPUnit step names the extension's own tables, and api_keys, by
  their models in prepareDatabase().
- fl make backend model generates the factory with the model.

* fix(upgrade): put #[Test] first again when converting annotations

The PHPUnit 12 rewrite in #58 wrote attributes in the order the
annotations were written, so a test with @dataProvider above @test got
#[DataProvider] above #[Test]. The original rewriter put #[Test] first,
as Flarum's own tests have it. Found by running both versions over the
1.x tests of 36 FoF extensions and core.
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