Problem/Motivation

In Core 11.2-dev #3497431: Deprecate TestDiscovery test file scanning, use PHPUnit API instead was introduced, but broke Contrib testing and has been reverted.

This has now been fixed, and re-committed to 11.2.x so the tests run, but give deprecation warnings about missing attribute metadata.

Remaining tasks

Add #[Group('scheduler')] (or the appropriate group) to each phpunit test classes.
Add #[DataProvider(' ... ')] to each dataprovider function.

Issue fork scheduler-3527579

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

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Need to remove the 3rd-party deprecation warnings so that we can see what actually needs to be done for Scheduler. Initial results as-is before any work, split by test @group:

  • scheduler - 23 tests triggered deprecations (all range between 54 and 74 deps) = too many add up accurately. Log is 41K lines
  • scheduler_api, 63 + 58 + 59 + 54 = 234 deprecations, log is 8K lines
  • scheduler_js - each test triggered 54 deprecations. Log is 3K, not too big.
  • scheduler_kernel - each test triggered 7-9 deprecations. Log 890 lines.
  • scheduler_rules_integration - each test triggered between 67-74 deprecations. Log is 8K lines
  • scheduler_workbench - 68 deprecations. Log 1300 lines.
jonathan1055’s picture

First round of 3rd-party ignores. Big improvements made:

  • scheduler - 23 tests triggered deprecations (12-15 deps each). Log is 12K lines
  • scheduler_api, each 12 - 13 deprecations, log is 2,900 lines
  • scheduler_js - each test triggered 11 deprecations. Log is 1,500
  • scheduler_kernel - each test triggered 7-9 deprecations. Log 890 lines (no change).
  • scheduler_rules_integration - each test triggered 16 deprecations. Log is 3,100 lines
  • scheduler_workbench - 22 12 deprecations. Log 780 lines.

Many All of these are for Scheduler.

  • jonathan1055 committed 2b111a55 on 2.x
    Issue #3527579 by jonathan1055: Ignore 3-party deprecations in phpunit...
jonathan1055’s picture

After adding group attributes for scheduler_js the DefaultTime test shows:
Before: There were 27 PHPUnit test runner deprecations
After: There were 18 PHPUnit test runner deprecations.
The 9 removed messages were all

Metadata found in doc-comment for class Drupal\Tests\scheduler\FunctionalJavascript\SchedulerJavascriptDefaultTimeTest. Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

Likewise the verticalTabs test had 36 before down to 27 after.

So that's good. Even though the @group scheduler_js is still in the doc-comment, providing there is also the new #[Group('scheduler_js')] then the phpunit test runner deprecation is not displayed. That should mean we can fix the code for the new core 11.2+ and still support testing at the old core versions.

mondrake’s picture

As per #3497431-107: Deprecate TestDiscovery test file scanning, use PHPUnit API instead, you may opt-out from reporting PHPUnit runner deprecations (if they're too noisy for now), by setting the env variable PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION to FALSE.

jonathan1055’s picture

Issue summary: View changes

Thanks, yes that worked. After adding #[DataProvider()] to go with each @dataProvider in the javascript tests we still had the message There were 9 PHPUnit test runner deprecations followed by 8 tests triggered 11 deprecations. The 9 were all for core functions, after I had fixed the project's own ones.
https://git.drupalcode.org/project/scheduler/-/jobs/5598340#L663

With PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION: 0 we just get straight to 8 tests triggered 11 deprecations
https://git.drupalcode.org/project/scheduler/-/jobs/5599415#L661

Thanks also for raising #3530202: Introduce PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION

  • jonathan1055 committed bde29e6c on 2.x
    Issue #3527579: Add #[Group] attributes for Core 11.2 and PHPUnit 11
    

  • jonathan1055 committed b868c721 on 2.x
    [#3527579] feat: Add #[Group] and #[DataProvider] attributes to test...
jonathan1055’s picture

Issue summary: View changes
Status: Active » Fixed

I have merged the main work MR242. This requied the new PHPStan (previous Major) job to be skipped as the new attributes and classes have not been backported to Drupal 10. However, there should not be any problem with running on a Drupal 10 site, as the attribute classes will not be examined or used in any way.
See this slack discussion on the subject. Specifically

using a non-existing class is still valid, you just can't call it or anything in it. That comes to our benefit when we have e.g. a plugin that will only be used when some other module is installed. And if not, that plugin with strictly speaking invalid use statements will just sit around silently, not doing anything.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

jonathan1055’s picture

Title: Add #[Group] attributes for Core 11.2 and PHPUnit 11 » Add #[Group] and #[DataProvider] attributes for PHPUnit 11

Status: Fixed » Closed (fixed)

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