Problem/Motivation

DrupalStandardsListenerTrait has been broken since issue #3186443: PHPUnit 9.5 Call to undefined method ::getAnnotations().

1) the test class passed in for finding the annotations is the listener's itself, not the test one
2) the test method passed in the the test name, which in case of tests with dataproviders includes the dataset name

Proposed ultimate resolution as conceived by @mondrake

Actually, remove DrupalStandardsListenerTrait altogether - phpstan/phpstan-phpunit is better at doing these checks, and helped find out this issue. Therefore, complete #3326239: Add phpstan/phpstan-phpunit as a dev dependency, and once done that, remove DrupalStandardsListenerTrait. That would also help in future efforts to migrate to PHPUnit 10 that drops the usage of listeners.

Proposed resolution for this issue

- Fix DrupalStandardsListenerTrait
- Fix new errors that were not discovered due to DrupalStandardsListenerTrait being broken

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3335406

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

A test-only patch to prove the problem.

mondrake’s picture

Issue summary: View changes
Issue tags: +PHPUnit 10
Spokje’s picture

Nice sleuthing there @mondrake!

Seeing that the general consensus amongst release managers in #3326239: Add phpstan/phpstan-phpunit as a dev dependency seems to be that we need to split that issue up, maybe we can:

1) Fix DrupalStandardsListenerTrait and its currently not detected errors in here. That would make #3326239: Add phpstan/phpstan-phpunit as a dev dependency a lot smaller.
2) After 1) is committed, we update the MR in #3326239: Add phpstan/phpstan-phpunit as a dev dependency.
3) After 2) is committed, we start on a new issue for removing DrupalStandardsListenerTrait.

To me it seems that this way everybody is happy/happier.

It does mean a bit more admin overhead because there are more issues, but it seems to be the quickest way to get things done?

Spokje’s picture

Assigned: Unassigned » Spokje
Status: Active » Needs work
Spokje’s picture

Issue summary: View changes

mondrake’s picture

The @covers in the [driver]DriverLegacyTest classes

  /**
   * @covers Drupal\Core\Database\Driver\pgsql\Install\Tasks
   */

should just be removed IMHO - they trigger deprecations at the class autoloading time that phpunit-bridge cannot capture, and in any case those are just stub classes, there's no purpose in @covering them. Doing that you can leave the stubbed classes alone.

mondrake’s picture

I can already see people complaining if we remove the docblock. Maybe change to

  /**
   * Tests deprecation of Drupal\Core\Database\Driver\pgsql\Install\Tasks
   */
Spokje’s picture

Thanks @mondrake, I was trying to find out what triggered the (newly found) deprecations.
Might have eventually ended up with the @covers triggering them, but you were way ahead of me :)

Did however arrived at not-deleting-the-docblock-completely around the same time as you.

mondrake’s picture

For the database specific schema test issues, I think it should suffice adding the abstract class Drupal\Core\Database\Schema to the @covers of the abstract class DriverSpecificSchemaTestBase, like

  /**
   * Tests various schema changes' effect on the table's primary key.
   *
   * @param array $initial_primary_key
   *   The initial primary key of the test table.
   * @param array $renamed_primary_key
   *   The primary key of the test table after renaming the test field.
   *
   * @dataProvider providerTestSchemaCreateTablePrimaryKey
   *
   * @covers \Drupal\Core\Database\Schema::addField
   * @covers \Drupal\Core\Database\Schema::changeField
   * @covers \Drupal\Core\Database\Schema::dropField
   * @covers \Drupal\Core\Database\Schema::findPrimaryKeyColumns
   */

and only in case of the test method being overridden at the specific database concrete test class, then specify a @covers for the driver's schema class.

No idea about why the listener test itself throw a deprecation, tho...

mondrake’s picture

... exactly what you did ... :)

Spokje’s picture

I have my moments ;)

Spokje’s picture

Assigned: Spokje » Unassigned
Status: Needs work » Needs review
mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs followup

This mostly looks good to me and (unlike #3326239: Add phpstan/phpstan-phpunit as a dev dependency) is mostly only fixing fails that can be evaluated within the context of the diff.

I reviewed the MR and left a few questions, a nitpick, and a request for at least an inline comment if not tests for the bugfix.

Tagging "Needs followup" for the place where the test method names are a lie.

mondrake’s picture

Added comments on the MR.

mondrake’s picture

alexpott’s picture

Status: Needs work » Closed (won't fix)