.../editor/src/Tests/QuickEditIntegrationTest.php | 16 +++++++++++++++- core/modules/system/src/Tests/Ajax/CommandsTest.php | 13 ++++++++++++- core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php | 13 ++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php index ab48237..cb67445 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -8,6 +8,7 @@ namespace Drupal\editor\Tests; use Drupal\Component\Serialization\Json; +use Drupal\Core\EventSubscriber\AjaxSubscriber; use Drupal\Core\Language\LanguageInterface; use Drupal\quickedit\EditorSelector; use Drupal\quickedit\MetadataGenerator; @@ -16,6 +17,8 @@ use Drupal\quickedit_test\MockEditEntityFieldAccessCheck; use Drupal\editor\EditorController; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Tests Edit module integration (Editor module's inline editing support). @@ -214,7 +217,18 @@ public function testGetUntransformedTextCommand() { 'data' => 'Test', ) ); - $this->assertEqual(Json::encode($expected), $response->prepare($request)->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.'); + + $ajax_response_attachments_processor = \Drupal::service('ajax_response.attachments_processor'); + $subscriber = new AjaxSubscriber($ajax_response_attachments_processor); + $event = new FilterResponseEvent( + \Drupal::service('http_kernel'), + $request, + HttpKernelInterface::MASTER_REQUEST, + $response + ); + $subscriber->onResponse($event); + + $this->assertEqual(Json::encode($expected), $response->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.'); } } diff --git a/core/modules/system/src/Tests/Ajax/CommandsTest.php b/core/modules/system/src/Tests/Ajax/CommandsTest.php index 969ec9c..711aad2 100644 --- a/core/modules/system/src/Tests/Ajax/CommandsTest.php +++ b/core/modules/system/src/Tests/Ajax/CommandsTest.php @@ -23,7 +23,10 @@ use Drupal\Core\Ajax\RemoveCommand; use Drupal\Core\Ajax\RestripeCommand; use Drupal\Core\Ajax\SettingsCommand; +use Drupal\Core\EventSubscriber\AjaxSubscriber; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * Performs tests on AJAX framework commands. @@ -133,7 +136,15 @@ public function testAttachedSettings() { 'drupalSettings' => ['foo' => 'bar'], ]); - $response->prepare(new Request()); + $ajax_response_attachments_processor = \Drupal::service('ajax_response.attachments_processor'); + $subscriber = new AjaxSubscriber($ajax_response_attachments_processor); + $event = new FilterResponseEvent( + \Drupal::service('http_kernel'), + new Request(), + HttpKernelInterface::MASTER_REQUEST, + $response + ); + $subscriber->onResponse($event); $expected = [ 'command' => 'settings', ]; diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php index 19bbe8d..482bf75 100644 --- a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php +++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php @@ -8,9 +8,12 @@ namespace Drupal\Tests\Core\Ajax; use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\EventSubscriber\AjaxSubscriber; use Drupal\Core\Render\Element\Ajax; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\HttpKernelInterface; /** * @coversDefaultClass \Drupal\Core\Ajax\AjaxResponse @@ -81,7 +84,15 @@ public function testPrepareResponseForIeFormRequestsWithFileUpload() { $response = new AjaxResponse([]); $response->headers->set('Content-Type', 'application/json; charset=utf-8'); - $response->prepare($request); + $ajax_response_attachments_processor = $this->getMock('\Drupal\Core\Render\AttachmentsResponseProcessorInterface'); + $subscriber = new AjaxSubscriber($ajax_response_attachments_processor); + $event = new FilterResponseEvent( + $this->getMock('\Symfony\Component\HttpKernel\HttpKernelInterface'), + $request, + HttpKernelInterface::MASTER_REQUEST, + $response + ); + $subscriber->onResponse($event); $this->assertEquals('text/html; charset=utf-8', $response->headers->get('Content-Type')); $this->assertEquals($response->getContent(), ''); }