Problem/Motivation

When running PHPUnit tests on Drupal 11 for the scheduler module, it throws below error:

Error: Call to undefined method Drupal\Tests\scheduler\Functional\SchedulerPermissionsTest::getName()

/Users/user1/drupal11.0.0-beta1/docroot/modules/contrib/scheduler/tests/src/Functional/SchedulerBrowserTestBase.php:59
/Users/user1/drupal11.0.0-beta1/docroot/modules/contrib/scheduler/tests/src/Functional/SchedulerPermissionsTest.php:48

Steps to reproduce

  • Setup a Drupal 11 project.
  • Download the Scheduler module.
  • Run PHPUnit tests against it and you'll see above error.

Proposed resolution

The reason it thorws above error, because the setup() function in SchedulerBrowserTestBase.php invokes $this->getName(), the getName function exists until PHPUnit 9.5, but it doesn't exists on PHPUnit 10.
So, as an alternative, we should use $this->toString() method.

Issue fork scheduler-3458430

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

vishalkhode created an issue. See original summary.

deepakkm made their first commit to this issue’s fork.

deepakkm’s picture

Status: Active » Needs review
vishalkhode’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed changes and looks good to me.

jonathan1055’s picture

Changed parent to related issue.

The phpunit tests all fail at D11. That is not necessarily the fault of this MR, but the overall 'next major' testing needs to be sorted out before I can release a Drupal 11 compatible version of Scheduler.

vishalkhode’s picture

Hi @jonathan1055
Yes, there are couple of Drupal 11 tests failing (not all). I've described the complete Drupal 11 status here. Also, I've added some commits in #3434325: Drupal 11 compatibility fixes [2.x] to run PHPUnit tests on Drupal 11. Can we merge changes for this ticket as we need to fix this for Drupal 11.

The phpunit tests all fail at D11. That is not necessarily the fault of this MR, but the overall 'next major' testing needs to be sorted out before I can release a Drupal 11 compatible version of Scheduler.

jonathan1055’s picture

Category: Bug report » Task

Thanks for making this MR. Just checked locally and using toString() actually provides more information than we had before.

getName() returns testViewScheduledContentOverview with data set "#commerce_product"

toString() returns Drupal\Tests\scheduler\Functional\SchedulerViewsAccessTest::testViewScheduledContentOverview with data set "#commerce_product" ('commerce_product', 'test_product')

But this should not affect the outcome of the stristr() condition

jonathan1055’s picture

Status: Reviewed & tested by the community » Fixed

Previously we had errors in PHPstan

  Line   tests/src/Functional/SchedulerBrowserTestBase.php                       
 ------ ------------------------------------------------------------------------ 
  59     Call to an undefined method                                             
         Drupal\Tests\scheduler\Functional\SchedulerBrowserTestBase::getName().  

and with this MR the PHPstan Next Major is green and clean.

The PHPUnit tests also all had

Error: Call to undefined method
Drupal\Tests\scheduler\Functional\the-test-name::getName()

and these are now solved with this MR.

Also, the tests pass at Current and Previous Major (so we maintain backwards compatibility with Drupal 9.5)

Thank you @deepakkm and @vishalkhode. Merged and fixed.

Status: Fixed » Closed (fixed)

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