Problem/Motivation

in #3353210: [PHPUnit 10] @dataProvider methods must be declared static and public we set all data provider methods to static, however the provider source in MigrateSourceTestBase is a special case, being an abstract method in a base class widely extended in contrib migrate modules. Having the abstract class declared static will prevent extending classes from having a version of code that works with both 10.2 and 10.3. While our BC promise does not apply to test classes, this particular case will be fairly disruptive, and we should avoid it if we can.

Steps to reproduce

Proposed resolution

Remove the abstract class and document that extending classes should implement the providerSource method as a static method. Current code will continue to work until the full switchover to phpUnit 10 in D11. This will allow modules to have code that works with both 10.2 and 10.3 by not declaring the method static, and code that works with both 10.3 and 10.4/11.0 by adding a static declaration when they are ready.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#21 3437129-nr-bot.txt90 bytesneeds-review-queue-bot

Issue fork drupal-3437129

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mikelutz created an issue. See original summary.

mikelutz’s picture

Title: Remove » Remove Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::providerSource()
Issue tags: -Remove Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::providerSource() +migrate

mikelutz’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Not sure I 100% know that error but phpstan error

berdir’s picture

Priority: Normal » Major

Yeah, phpstan doesn't like this, so we need to add it to the baseline.

mikelutz’s picture

The @phpstan-ignore-next-line (on the line before the method declaration, not the @dataprovider line) worked when I ran the commit check script, but the CI doesn't like it, and I haven't gotten back to figuring out why yet.

mikelutz’s picture

Ah, because the commit check only checks the changed files, but another abstract class, MigrateSqlSourceTestBase extends MigrateSourceTestBase, and throws the same error now when all files are checked, and the names were similar enough that I didn't notice CI was complaining about a completely different file.. Okay, I added both to the baseline. Hopefully, this one works.

mikelutz’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Good find! All green and change seems fine to me.

mondrake’s picture

Issue tags: +PHPUnit 10

  • catch committed 77368276 on 10.3.x
    Issue #3437129 by mikelutz: Remove Drupal\Tests\migrate\Kernel\...

  • catch committed fb9591f0 on 11.x
    Issue #3437129 by mikelutz: Remove Drupal\Tests\migrate\Kernel\...
catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Makes sense, I opened #3437318: Add back Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::providerSource() for 10.4 and 110/11.1 since we should be able to do that when we're going to drop 10.2 support.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

berdir’s picture

Status: Closed (fixed) » Reviewed & tested by the community

Unfortunately the BC layer here only works in one direction, when the method is declared as non-static.

When you try to make it static for D11 then the tests fail on 10.2 with:

PHP Fatal error: Cannot make non static method Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::providerSource() static in class Drupal\Tests\paragraphs\Kernel\migrate\ParagraphsTypeSourceTest in /builds/project/paragraphs/tests/src/Kernel/migrate/ParagraphsTypeSourceTest.php on line 25

See https://git.drupalcode.org/project/paragraphs/-/jobs/1683642.

Can we backport this to 10.2.x as well?

catch’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

I think it's safe to backport, it's almost entirely a docs change, removing an abstract method can't affect anything. However it needs a backport MR, 10.3.x commit doesn't cherry-pick cleanly.

mikelutz changed the visibility of the branch 3437129- to hidden.

mikelutz’s picture

Status: Patch (to be ported) » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

mikelutz’s picture

Status: Needs work » Needs review
Issue tags: +no-needs-review-bot
berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

  • catch committed 9c0d2f6b on 10.2.x
    Issue #3437129 by mikelutz, Berdir, catch: Remove abstract method Drupal...

catch’s picture

Version: 10.3.x-dev » 10.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.2.x, thanks! Customized the commit message because it sounds scary removing a method but we're only removing an abstract method that's now causing breakage, any module already written against 10.2.x will already work exactly the same before/after, so there's no actual bc concern, just a forwards compatibility improvement.

berdir’s picture

Thanks for the quick turnaround. I can confirm that paragraph tests can be run against 10.2/10.3/11.0 (with varying amount of fails on all branches, but they *run*)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.