diff --git a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php index 67bd849498..f0b4bc25d6 100644 --- a/core/modules/page_cache/tests/src/Functional/PageCacheTest.php +++ b/core/modules/page_cache/tests/src/Functional/PageCacheTest.php @@ -521,24 +521,25 @@ public function testCacheableResponseResponses() { * Tests that HEAD requests are treated the same as GET requests. */ public function testHead() { + $client = $this->getSession()->getDriver()->getClient()->getClient(); // GET, then HEAD. $url_a = $this->buildUrl('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'bar']]); - $response_body = $this->curlExec([CURLOPT_HTTPGET => TRUE, CURLOPT_URL => $url_a, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_NOBODY => FALSE]); + $response_body = $this->drupalGet($url_a); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); $this->assertEqual('The following header was set: Foo: bar', $response_body); - $response_body = $this->curlExec([CURLOPT_HTTPGET => FALSE, CURLOPT_URL => $url_a, CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => FALSE]); + $response_body = $client->request('HEAD', $url_a); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', 'Custom header was sent.'); $this->assertEqual('', $response_body); // HEAD, then GET. $url_b = $this->buildUrl('system-test/set-header', ['query' => ['name' => 'Foo', 'value' => 'baz']]); - $response_body = $this->curlExec([CURLOPT_HTTPGET => FALSE, CURLOPT_URL => $url_b, CURLOPT_CUSTOMREQUEST => 'HEAD', CURLOPT_NOBODY => FALSE]); + $response_body = $client->request('HEAD', $url_b); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'baz', 'Custom header was sent.'); $this->assertEqual('', $response_body); - $response_body = $this->curlExec([CURLOPT_HTTPGET => TRUE, CURLOPT_URL => $url_b, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_NOBODY => FALSE]); + $response_body = $this->drupalGet($url_b); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->assertEqual($this->drupalGetHeader('Foo'), 'baz', 'Custom header was sent.'); $this->assertEqual('The following header was set: Foo: baz', $response_body); diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index 9c8bbcdb7c..cb793746b0 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -1422,15 +1422,15 @@ protected function checkForMetaRefresh() { /** * Retrieves only the headers for a Drupal path or an absolute path. * - * @param $path - * Drupal path or URL to load into internal browser - * @param $options + * @param \Drupal\Core\Url|string $path + * Drupal path or URL to load into internal browser. + * @param array $options * Options to be forwarded to the url generator. - * @param $headers + * @param array $headers * An array containing additional HTTP request headers, each formatted as * "name: value". * - * @return + * @return array * The retrieved headers, also available as $this->getRawContent() */ protected function drupalHead($path, array $options = [], array $headers = []) {