Replace the deprecated xpath() test helper with a form that works on both supported core versions

BrowserTestBase::xpath() is deprecated in Drupal 11.5 and removed in Drupal 13, so the next-major lane failed on both of its call sites in tests/src/Functional/WorkflowVariablesUiTest.php: phpstan (next major) reported two method.deprecated errors and phpunit (next major) exited 1 on the deprecation. Both jobs are allow_failure, so the pipeline badge stayed green over it, and every open merge request off the current 1.x shows the same two lines.

Why not the replacement the notice names

getNodeElementsByXpath() arrives in Drupal 11.5. The main phpunit job installs core 11.4.5, where it does not exist, and the project declares ^11.3 || ^12, so switching to it would fatal the lane that is currently green.

Why not a deprecation-ignore

#[IgnoreDeprecations] would silence phpunit (next major) and do nothing for phpstan (next major), which fails on a different rule, so it fixes one of the two red jobs and needs a second suppression for the other. The project's own device for phpstan, a test whose scope is itself @deprecated, does not apply here: this class tests the variables UI table layout and outlives xpath(), so the tag would say something false about it. Both routes also keep a call that is removed in 13.

What this does instead

xpath() builds the query from its $arguments and hands it to Mink. Neither call site passes arguments, and buildXPathQuery() with an empty array returns the query untouched, so the two calls are the findAll() underneath them and nothing else:

$page = $this->getSession()->getPage();
$this->assertCount(2, $page->findAll('xpath', '//table//tbody/tr[1]/td'));

Stable on every supported version, survives the removal in 13, and adds no suppression device anywhere. The page is resolved once and reused, since both calls query the same one.

Verified

phpcs and phpstan clean locally. The two next-major jobs and the main phpunit job are the real check and are read individually rather than off the badge, since the lint and next-major jobs are allow_failure here.

Merge request reports

Loading
Loading