diff --git a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php index 93d7471..f4b4506 100644 --- a/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php @@ -174,7 +174,7 @@ protected function onJson(GetResponseForExceptionEvent $event) { // of message to be displayed, $data = []; if (error_displayable($error) && $message = $exception->getMessage()) { - $data = [$message]; + $data = [sprintf('A fatal error occurred: %s', $message)]; } $response = new JsonResponse($data, Response::HTTP_INTERNAL_SERVER_ERROR); diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php index 7befb00..5f13978 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php @@ -39,7 +39,7 @@ protected static function getPriority() { * The event to process. */ public function on403(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(NULL, Response::HTTP_FORBIDDEN); + $response = new JsonResponse([], Response::HTTP_FORBIDDEN); $event->setResponse($response); } @@ -50,7 +50,7 @@ public function on403(GetResponseForExceptionEvent $event) { * The event to process. */ public function on404(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(NULL, Response::HTTP_NOT_FOUND); + $response = new JsonResponse([], Response::HTTP_NOT_FOUND); $event->setResponse($response); } @@ -61,7 +61,7 @@ public function on404(GetResponseForExceptionEvent $event) { * The event to process. */ public function on405(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(NULL, Response::HTTP_METHOD_NOT_ALLOWED); + $response = new JsonResponse([], Response::HTTP_METHOD_NOT_ALLOWED); $event->setResponse($response); } diff --git a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php index 3de74b1..afdb728 100644 --- a/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditLoadingTest.php @@ -84,7 +84,7 @@ public function testUserWithoutPermission() { // Retrieving the metadata should result in an empty 403 response. $post = array('fields[0]' => 'node/1/body/en/full'); $response = $this->drupalPost('quickedit/metadata', 'application/json', $post); - $this->assertIdentical('{}', $response); + $this->assertIdentical('[]', $response); $this->assertResponse(403); // Quick Edit's JavaScript would SearchRankingTestnever hit these endpoints if the metadata @@ -261,7 +261,6 @@ public function testUserWithPermission() { ); $post += $edit + $this->getAjaxPageStatePostData(); $response = $this->drupalPost('quickedit/form/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', $post); - $this->assertIdentical('[]', $response); $this->assertResponse(200); $ajax_commands = Json::decode($response); $this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.'); @@ -271,8 +270,11 @@ public function testUserWithPermission() { // Save the entity. $post = array('nocssjs' => 'true'); $response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post); - $this->assertIdentical('[]', $response); $this->assertResponse(200); + $ajax_commands = Json::decode($response); + $this->assertIdentical(1, count($ajax_commands)); + $this->assertIdentical('quickeditEntitySaved', $ajax_commands[0]['command'], 'The first AJAX command is an quickeditEntitySaved command.'); + $this->assertEqual($ajax_commands[0]['data'], ['entity_type' => 'node', 'entity_id' => 1], 'Updated entity type and ID returned'); // Test that a revision was created with the correct log message. $vids = \Drupal::entityManager()->getStorage('node')->revisionIds(node_load(1)); diff --git a/core/modules/rest/src/Tests/AuthTest.php b/core/modules/rest/src/Tests/AuthTest.php index b53beaf..dd8b3f4 100644 --- a/core/modules/rest/src/Tests/AuthTest.php +++ b/core/modules/rest/src/Tests/AuthTest.php @@ -39,7 +39,7 @@ public function testRead() { // Try to read the resource as an anonymous user, which should not work. $this->httpRequest($entity->getSystemPath(), 'GET', NULL, $this->defaultMimeType); $this->assertResponse('401', 'HTTP response code is 401 when the request is not authenticated and the user is anonymous.'); - $this->assertText('A fatal error occurred: No authentication credentials provided.'); + $this->assertRaw(json_encode(['A fatal error occurred: No authentication credentials provided.'])); // Ensure that cURL settings/headers aren't carried over to next request. unset($this->curlHandle);