function RESTTestBase::assertResponseBody

Check to see if the HTTP request response body is identical to the expected value.

Parameters

$expected: The first value to check.

$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 'Other'; most tests do not override this default.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

File

core/modules/rest/src/Tests/RESTTestBase.php, line 583

Class

RESTTestBase
Test helper class that provides a REST client method to send HTTP requests.

Namespace

Drupal\rest\Tests

Code

protected function assertResponseBody($expected, $message = '', $group = 'REST Response') {
    return $this->assertIdentical($expected, $this->responseBody, $message ? $message : strtr('Response body @expected (expected) is equal to @response (actual).', [
        '@expected' => var_export($expected, TRUE),
        '@response' => var_export($this->responseBody, TRUE),
    ]), $group);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.