diff --git a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php index 25ea1a105424fa1f23e3423b12a2c66b951f46b2..a6d9d84b2d739d0ec4668a347b75f847a8e9f19c 100644 --- a/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php +++ b/core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php @@ -102,7 +102,7 @@ public function testAcceptLanguageEmptyDefault(): void { $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); // Check with browser without language settings - should return fallback language. - $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => NULL]); + $this->drupalGet('/system-test/echo/language test', [], ['Accept-Language' => '']); $this->assertSession()->responseHeaderEquals('Content-Language', 'en'); $this->assertSession()->responseHeaderDoesNotExist('X-Drupal-Cache'); diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index c7cca3ed5d5f605672e3198ef63242c4bf588611..becdbd90b4b8bda86971afd8511d7de2f38d592f 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -1059,13 +1059,13 @@ public function enableMenuLink(MenuLinkContent $item) { public function testMenuParentsJsAccess(): void { $this->drupalLogin($this->drupalCreateUser(['administer menu'])); // Just check access to the callback overall, the POST data is irrelevant. - $this->drupalGet('admin/structure/menu/parents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']); + $this->drupalGet('admin/structure/menu/parents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $this->assertSession()->statusCodeEquals(200); // Log in as authenticated user. $this->drupalLogin($this->drupalCreateUser()); // Check that a simple user is not able to access the menu. - $this->drupalGet('admin/structure/menu/parents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']); + $this->drupalGet('admin/structure/menu/parents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $this->assertSession()->statusCodeEquals(403); } diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index c26b5d76012c289be03fe09aac3f3be4cfb7d9dc..6d12f1b09c854db6b8729d0aa450d1276b50192b 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -194,7 +194,7 @@ public function testConditionalRequests(): void { $this->assertSession()->statusCodeEquals(304); // Ensure a conditional request without If-None-Match returns 200 OK. - $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => NULL]); + $this->drupalGet('', [], ['If-Modified-Since' => $last_modified, 'If-None-Match' => '']); // Verify the page is not printed twice when the cache is warm. $this->assertSession()->responseNotMatches('#<html.*<html#'); $this->assertSession()->statusCodeEquals(200); diff --git a/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php b/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php index 2a4005a510b5aa45403aaac8b7125a1cd0d9db46..f00d1b15aced8a3b08e9ddc6f64578d727bcfc10 100644 --- a/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php +++ b/core/modules/rest/tests/src/Functional/Views/StyleSerializerEntityTest.php @@ -338,7 +338,7 @@ public function testResponseFormatConfiguration(): void { $this->submitForm([], 'Save'); // Should return a 406. Emulates a sample Firefox header. - $this->drupalGet('test/serialize/field', [], ['Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']); + $this->drupalGet('test/serialize/field', [], ['Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8']); $this->assertSession()->responseHeaderEquals('content-type', 'text/html; charset=UTF-8'); $this->assertSession()->statusCodeEquals(406); diff --git a/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php b/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php index 037e0de5115b880935ffacfdf42778fa4cb66e3f..4e5695141b6af1a1ad9714ce2608fb17dce59796 100644 --- a/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php +++ b/core/modules/system/tests/src/Functional/Ajax/FrameworkTest.php @@ -149,7 +149,7 @@ protected function assertCommand(array $haystack, array $needle): void { * Decoded JSON. */ protected function drupalGetAjax($path, array $options = [], array $headers = []) { - $headers[] = 'X-Requested-With: XMLHttpRequest'; + $headers = ['X-Requested-With' => 'XMLHttpRequest']; if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT])) { $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax'; } diff --git a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php index 3e49149c53f0a618936120fff769d3ef846dde84..cb9806f8b093f4788254b522ca783ee9e7343eb1 100644 --- a/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php +++ b/core/modules/system/tests/src/Functional/DrupalKernel/ContentNegotiationTest.php @@ -45,7 +45,7 @@ public function testBogusAcceptHeader(): void { 'Android #2 (2012)' => 'text/xml,text/html,application/xhtml+xml,image/png,text/plain,*/*;q=0.8', ]; foreach ($tests as $case => $header) { - $this->drupalGet('', [], ['Accept: ' . $header]); + $this->drupalGet('', [], ['Accept' => $header]); $this->assertSession()->pageTextNotContains('Unsupported Media Type'); $this->assertSession()->pageTextContains('Log in'); } diff --git a/core/modules/system/tests/src/Functional/Form/StorageTest.php b/core/modules/system/tests/src/Functional/Form/StorageTest.php index 9b3997c2b23cc537c392a9d98873a5c623b08395..dcc7ffc594b4d0c1ce37f03789fff0b538bef03e 100644 --- a/core/modules/system/tests/src/Functional/Form/StorageTest.php +++ b/core/modules/system/tests/src/Functional/Form/StorageTest.php @@ -191,7 +191,7 @@ public function testImmutableFormLegacyProtection(): void { $build_id = $this->assertSession()->hiddenFieldExists('form_build_id')->getValue(); // Try to poison the form cache. - $response = $this->drupalGet('form-test/form-storage-legacy/' . $build_id, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']); + $response = $this->drupalGet('form-test/form-storage-legacy/' . $build_id, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $original = json_decode($response, TRUE); $this->assertEquals($original['form']['#build_id_old'], $build_id, 'Original build_id was recorded'); @@ -208,7 +208,7 @@ public function testImmutableFormLegacyProtection(): void { $this->assertTrue($status, 'A watchdog message was logged by \Drupal::formBuilder()->setCache'); // Ensure that the form state was not poisoned by the preceding call. - $response = $this->drupalGet('form-test/form-storage-legacy/' . $build_id, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']); + $response = $this->drupalGet('form-test/form-storage-legacy/' . $build_id, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $original = json_decode($response, TRUE); $this->assertEquals($original['form']['#build_id_old'], $build_id, 'Original build_id was recorded'); $this->assertNotEquals($original['form']['#build_id'], $build_id, 'New build_id was generated'); diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index ead1cd8956ac5829ffa03e71c61e9f0af5097ca1..5208c73b873c666f4e03bc4952c0ddb38763212c 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -298,7 +298,7 @@ public function testControllerResolutionAjax(): void { // This will fail with a JSON parse error if the request is not routed to // The correct controller. $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax'; - $headers[] = 'X-Requested-With: XMLHttpRequest'; + $headers = ['X-Requested-With' => 'XMLHttpRequest']; $this->drupalGet('/router_test/test10', $options, $headers); $this->assertSession()->responseHeaderEquals('Content-Type', 'application/json'); diff --git a/core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php b/core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php index 61cb40d64a4ce43efcb27da14b176402eab93d90..0f3856140cf949479f949d8dc094d4dbdc62c3d0 100644 --- a/core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php +++ b/core/modules/system/tests/src/Functional/Session/StackSessionHandlerIntegrationTest.php @@ -29,7 +29,7 @@ class StackSessionHandlerIntegrationTest extends BrowserTestBase { */ public function testRequest(): void { $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax'; - $headers[] = 'X-Requested-With: XMLHttpRequest'; + $headers = ['X-Requested-With' => 'XMLHttpRequest']; $actual_trace = json_decode($this->drupalGet('session-test/trace-handler', $options, $headers)); $sessionId = $this->getSessionCookies()->getCookieByName($this->getSessionName())->getValue(); $expect_trace = [ diff --git a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php index 39faebd2bb9fbfb5eebd30da2f71511e948ee89f..7565eeb83c4da5c973ba5447465591d28f208ff6 100644 --- a/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php @@ -385,7 +385,7 @@ public function testSubtreesJsonRequest(): void { // Request a new page to refresh the drupalSettings object. $subtrees_hash = $this->getSubtreesHash(); - $this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']); + $this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With' => 'XMLHttpRequest']); $ajax_result = json_decode($this->getSession()->getPage()->getContent(), TRUE); $this->assertEquals('setToolbarSubtrees', $ajax_result[0]['command'], 'Subtrees response uses the correct command.'); $this->assertEquals(['system-admin_content', 'system-admin_structure', 'system-themes_page', 'system-modules_list', 'system-admin_config', 'entity-user-collection', 'front'], array_keys($ajax_result[0]['subtrees']), 'Correct subtrees returned.'); diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php index 5e6e9176b10064ae5ec73a69724819f1f169744a..a1ea81aec367df7fa094755868c7cc9d0a7a1aa8 100644 --- a/core/tests/Drupal/Tests/UiHelperTrait.php +++ b/core/tests/Drupal/Tests/UiHelperTrait.php @@ -245,13 +245,11 @@ protected function drupalGet($path, array $options = [], array $headers = []) { $this->prepareRequest(); foreach ($headers as $header_name => $header_value) { if (is_int($header_name)) { - // @todo Trigger deprecation in - // https://www.drupal.org/project/drupal/issues/3421105. + @trigger_error('Passing an integer as header name to ' . __METHOD__ . '() is deprecated in drupal:11.1.0 and will be removed from drupal:12.0.0. Update the calling code to pass the header name as a key. See https://www.drupal.org/node/3456178', E_USER_DEPRECATED); [$header_name, $header_value] = explode(':', $header_value); } if (is_null($header_value)) { - // @todo Trigger deprecation in - // https://www.drupal.org/project/drupal/issues/3421105. + @trigger_error('Using null as a header value to ' . __METHOD__ . '() is deprecated in drupal:11.1.0 and will be removed from drupal:12.0.0. Use an empty string instead. See https://www.drupal.org/node/3456233', E_USER_DEPRECATED); $header_value = ''; } $session->setRequestHeader($header_name, $header_value);