From 8b3b8c67f16cf92724234101f1040684bbf8d90b Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Sun, 13 Sep 2015 17:44:32 +0100
Subject: [PATCH] Issue #2564547 by Mile23, ianthomas_uk: Remove calls to
 drupal_process_attached

---
 core/modules/system/src/Tests/Common/AddFeedTest.php  | 10 ++++++++--
 core/modules/system/src/Tests/Common/RenderTest.php   |  6 +++---
 core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php |  2 --
 core/tests/Drupal/KernelTests/KernelTestBase.php      | 11 ++++++++---
 4 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/core/modules/system/src/Tests/Common/AddFeedTest.php b/core/modules/system/src/Tests/Common/AddFeedTest.php
index a83f41bddc60..1aa6a444c50b 100644
--- a/core/modules/system/src/Tests/Common/AddFeedTest.php
+++ b/core/modules/system/src/Tests/Common/AddFeedTest.php
@@ -61,9 +61,15 @@ function testBasicFeedAddNoTitle() {
       $build['#attached']['feed'][] = [$feed_info['url'], $feed_info['title']];
     }
 
-    drupal_process_attached($build);
+    // Use the bare HTML page renderer to render our links.
+    $renderer = $this->container->get('bare_html_page_renderer');
+    $response = $renderer->renderBarePage(
+      $build, '', $this->container->get('theme.manager')->getActiveTheme()->getName()
+    );
+    // Glean the content from the response object.
+    $this->setRawContent($response->getContent());
 
-    $this->setRawContent(drupal_get_html_head());
+    // Assert that the content contains the RSS links we specified.
     foreach ($urls as $description => $feed_info) {
       $this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
     }
diff --git a/core/modules/system/src/Tests/Common/RenderTest.php b/core/modules/system/src/Tests/Common/RenderTest.php
index 11bb96abd92b..94ad431e8768 100644
--- a/core/modules/system/src/Tests/Common/RenderTest.php
+++ b/core/modules/system/src/Tests/Common/RenderTest.php
@@ -53,17 +53,17 @@ function testDrupalRenderThemePreprocessAttached() {
   }
 
   /**
-   * Tests drupal_process_attached().
+   * Tests that we get an exception when we try to attach an illegal type.
    */
   public function testDrupalProcessAttached() {
     // Specify invalid attachments in a render array.
     $build['#attached']['library'][] = 'core/drupal.states';
     $build['#attached']['drupal_process_states'][] = [];
     try {
-      drupal_process_attached($build);
+      $this->render($build);
       $this->fail("Invalid #attachment 'drupal_process_states' allowed");
     }
-    catch (\Exception $e) {
+    catch (\LogicException $e) {
       $this->pass("Invalid #attachment 'drupal_process_states' not allowed");
     }
   }
diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
index d9c5dfc6324a..565329f67a68 100644
--- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
+++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
@@ -222,8 +222,6 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
     }
     $output = $renderer->renderRoot($form);
 
-    drupal_process_attached($form);
-
     // These forms have the title built in, so set the title here:
     $title = $form_state->get('title') ?: '';
 
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index a09227b058b5..74a885e26ded 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -869,9 +869,14 @@ protected function disableModules(array $modules) {
    *   The rendered string output (typically HTML).
    */
   protected function render(array &$elements) {
-    $content = $this->container->get('renderer')->render($elements);
-    drupal_process_attached($elements);
-    $this->setRawContent($content);
+    // Use the bare HTML page renderer to render our links.
+    $renderer = $this->container->get('bare_html_page_renderer');
+    $response = $renderer->renderBarePage(
+      $build, '', $this->container->get('theme.manager')->getActiveTheme()->getName()
+    );
+
+    // Glean the content from the response object.
+    $this->setRawContent($response->getContent());
     $this->verbose('<pre style="white-space: pre-wrap">' . Html::escape($content));
     return $content;
   }
-- 
GitLab