Verified Commit 5ac43624 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3440169 by pooja_sharma, marcoliver, smustgrave, DYdave, alexpott: When...

Issue #3440169 by pooja_sharma, marcoliver, smustgrave, DYdave, alexpott: When using drupalGet(), provide an associative array for $headers

(cherry picked from commit 519cafc4)
parent 95a28486
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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');

+2 −2
Original line number Diff line number Diff line
@@ -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);
  }

+1 −1
Original line number Diff line number Diff line
@@ -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);
+1 −1
Original line number Diff line number Diff line
@@ -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);

+1 −1
Original line number Diff line number Diff line
@@ -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';
    }
Loading