diff --git a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php index ecf1a54..9737b4f 100644 --- a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php +++ b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php @@ -55,7 +55,7 @@ protected function setUp() { * Test comment row. */ public function testCommentRestExport() { - $this->drupalGet(sprintf('node/%d/comments', $this->nodeUserCommented->id()), [], ['Accept' => 'application/hal+json']); + $this->drupalGetWithFormat(sprintf('node/%d/comments', $this->nodeUserCommented->id()), 'hal_json'); $this->assertResponse(200); $contents = Json::decode($this->getRawContent()); $this->assertEqual($contents[0]['subject'], 'How much wood would a woodchuck chuck'); diff --git a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_rest.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_rest.yml index 2de8cdb..6350455 100644 --- a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_rest.yml +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_rest.yml @@ -386,6 +386,7 @@ display: uses_fields: false formats: json: json + hal_json: hal_json row: type: data_field options: diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index ca94591..735dbd5 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1405,6 +1405,26 @@ protected function drupalGetJSON($path, array $options = array(), array $headers } /** + * Retrieves a Drupal path or an absolute path for a given format. + * + * @param string $path + * Path to request AJAX from. + * @param string $format + * The wanted request format. + * @param array $options + * Array of URL options. + * @param array $headers + * Array of headers. + * + * @return mixed + * The result of the request. + */ + protected function drupalGetWithFormat($path, $format, array $options = array(), array $headers = array()) { + $options += ['query' => ['_format' => $format]]; + return Json::decode($this->drupalGet($path, $options, $headers)); + } + + /** * Requests a Drupal path in drupal_ajax format and JSON-decodes the response. */ protected function drupalGetAjax($path, array $options = array(), array $headers = array()) {