When using drupalGet(), provide an associative array for $headers

Created on 11 April 2024, 3 months ago
Updated 25 June 2024, about 17 hours ago

Problem/Motivation

I noticed this while working on https://www.drupal.org/project/admin_toolbar/issues/3407845 📌 GitlabCI support: Fix all jobs validation errors and PHPUnit tests RTBC , where a test in the newly set-up CI fails. This is because the test just extends ToolbarAdminMenuTest, where drupalGet is called thusly:

$this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']);

Resulting in this pipeline-error:

TypeError: Behat\Mink\Session::setRequestHeader(): Argument #1 ($name) must be of type string, int given, called in /builds/issue/admin_toolbar-3407845/web/core/tests/Drupal/Tests/UiHelperTrait.php on line 235

As the documentation for drupalGet() states:

An array containing additional HTTP request headers, the array keys are the header names and the array values the header values.

So in the above case it would be

$this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']);

Proposed resolution

Try and find all spots in the code where drupalGet() is called with headers where only one string per header instead of a key-value pair is used, and split them up.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

RTBC

Version

11.0 🔥

Component
PHPUnit 

Last updated about 17 hours ago

Created by

🇩🇪Germany marcoliver Neuss, NRW, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024