You are here

protected function RESTTestBase::assertResponseBody in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rest/src/Tests/RESTTestBase.php \Drupal\rest\Tests\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\Utility\SafeMarkup::format() 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.

2 calls to RESTTestBase::assertResponseBody()
NodeTest::testInvalidBundle in core/modules/rest/src/Tests/NodeTest.php
Test bundle normalization when posting using a simple string.
NodeTest::testMissingBundle in core/modules/rest/src/Tests/NodeTest.php
Test when the bundle is missing.

File

core/modules/rest/src/Tests/RESTTestBase.php, line 417
Contains \Drupal\rest\Tests\RESTTestBase.

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).', array(
    '@expected' => var_export($expected, TRUE),
    '@response' => var_export($this->responseBody, TRUE),
  )), $group);
}