You are here

protected function XmlSitemapTestBase::assertNoResponse in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/XmlSitemapTestBase.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapTestBase::assertNoResponse()

Assert the page does not respond with the specified response code.

Parameters

string $code: Response code. For example 200 is a successful page request. For a list of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.

string $message: Message to display.

string $group: Name of the group.

Return value

mixed Assertion result.

File

tests/src/Functional/XmlSitemapTestBase.php, line 155

Class

XmlSitemapTestBase
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

protected function assertNoResponse($code, $message = '', $group = 'Browser') {
  $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
  $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
  return $this
    ->assertFalse($match, $message ? $message : t('HTTP response not expected @code, actual @curl_code', [
    '@code' => $code,
    '@curl_code' => $curl_code,
  ]), t('Browser'));
}