protected function WebTestBase::assertResponse in Drupal 8
Asserts the page responds with the specified response code.
Parameters
$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.
$message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.
$group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Browser'; most tests do not override this default.
Return value
Assertion result.
9 calls to WebTestBase::assertResponse()
- AggregatorTestBase::updateFeedItems in core/
modules/ aggregator/ src/ Tests/ AggregatorTestBase.php - Updates the feed items.
- ContentTranslationUITestBase::doTestBasicTranslation in core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php - Tests the basic translation workflow.
- ContentTranslationUITestBase::doTestTranslationDeletion in core/
modules/ content_translation/ src/ Tests/ ContentTranslationUITestBase.php - Tests translation deletion.
- EntityWithUriCacheTagsTestBase::testEntityUri in core/
modules/ system/ src/ Tests/ Entity/ EntityWithUriCacheTagsTestBase.php - Tests cache tags presence and invalidation of the entity at its URI.
- RESTTestBase::assertResponse in core/
modules/ rest/ src/ Tests/ RESTTestBase.php - Asserts the page responds with the specified response code.
1 method overrides WebTestBase::assertResponse()
- RESTTestBase::assertResponse in core/
modules/ rest/ src/ Tests/ RESTTestBase.php - Asserts the page responds with the specified response code.
File
- core/
modules/ simpletest/ src/ WebTestBase.php, line 1976
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
protected function assertResponse($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
->assertTrue($match, $message ? $message : new FormattableMarkup('HTTP response expected @code, actual @curl_code', [
'@code' => $code,
'@curl_code' => $curl_code,
]), $group);
}