.../HtmlResponseBigPipeSubscriber.php | 1 - src/Render/BigPipe.php | 1 - src/Render/BigPipeResponse.php | 1 + src/Tests/BigPipePlaceholderTestCases.php | 32 +++++++++++++++------- src/Tests/BigPipeTest.php | 3 ++ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php b/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php index 9170fe2..31d1278 100644 --- a/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php +++ b/src/EventSubscriber/HtmlResponseBigPipeSubscriber.php @@ -110,7 +110,6 @@ class HtmlResponseBigPipeSubscriber implements EventSubscriberInterface { return; } - // Create a new BigPipeResponse. $big_pipe_response = new BigPipeResponse(); $big_pipe_response->setBigPipeService($this->bigPipe); diff --git a/src/Render/BigPipe.php b/src/Render/BigPipe.php index 9af1b0f..cf37306 100644 --- a/src/Render/BigPipe.php +++ b/src/Render/BigPipe.php @@ -264,7 +264,6 @@ class BigPipe implements BigPipeInterface { // Another placeholder was rendered and sent, track the set of asset // libraries sent so far. Any new settings also need to be tracked, so // they can be sent in ::sendPreBody(). - // @todo What if drupalSettings already was printed in the HTML
? That case is not yet handled. In that case, no-JS BigPipe would cause broken (incomplete) drupalSettings⦠This would not matter if it were only used if JS is not enabled, but that's not the only use case. However, this $cumulative_assets->setAlreadyLoadedLibraries(array_merge($cumulative_assets->getAlreadyLoadedLibraries(), $html_response->getAttachments()['library'])); $cumulative_assets->setSettings($html_response->getAttachments()['drupalSettings']); } diff --git a/src/Render/BigPipeResponse.php b/src/Render/BigPipeResponse.php index b8694e1..235a154 100644 --- a/src/Render/BigPipeResponse.php +++ b/src/Render/BigPipeResponse.php @@ -47,4 +47,5 @@ class BigPipeResponse extends HtmlResponse { return $this; } + } diff --git a/src/Tests/BigPipePlaceholderTestCases.php b/src/Tests/BigPipePlaceholderTestCases.php index 8f2f072..5514eb7 100644 --- a/src/Tests/BigPipePlaceholderTestCases.php +++ b/src/Tests/BigPipePlaceholderTestCases.php @@ -13,12 +13,14 @@ use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides BigPipe placeholder test cases for use in both unit tests and - * integration tests. + * BigPipe placeholder test cases for use in both unit and integration tests. * - * - Unit test: \Drupal\Tests\big_pipe\Unit\Render\Placeholder\BigPipeStrategyTest - * - Integration test for BigPipe with JS on: \Drupal\big_pipe\Tests\BigPipeTest::testBigPipe() - * - Integration test for BigPipe with JS off: \Drupal\big_pipe\Tests\BigPipeTest::testBigPipeNoJs() + * - Unit test: + * \Drupal\Tests\big_pipe\Unit\Render\Placeholder\BigPipeStrategyTest + * - Integration test for BigPipe with JS on: + * \Drupal\big_pipe\Tests\BigPipeTest::testBigPipe() + * - Integration test for BigPipe with JS off: + * \Drupal\big_pipe\Tests\BigPipeTest::testBigPipeNoJs() */ class BigPipePlaceholderTestCases { @@ -293,43 +295,53 @@ class BigPipePlaceholderTestCase { public $placeholderRenderArray; /** - * The expected BigPipe placeholder ID and corresponding render array and - * embedded AJAX response commands, if any. + * The expected BigPipe placeholder ID. * * (Only possible for HTML placeholders.) * * @var null|string */ public $bigPipePlaceholderId = NULL; + /** + * The corresponding expected BigPipe placeholder render array. + * * @var null|array */ public $bigPipePlaceholderRenderArray = NULL; + /** + * The corresponding expected embedded AJAX response. + * * @var null|array */ public $embeddedAjaxResponseCommands = NULL; /** - * The expected BigPipe no-JS placeholder and corresponding render array and - * embedded HTML response. + * The expected BigPipe no-JS placeholder. * * (Possible for all placeholders, HTML or non-HTML.) * * @var string */ public $bigPipeNoJsPlaceholder; + /** + * The corresponding expected BigPipe no-JS placeholder render array. + * * @var array */ public $bigPipeNoJsPlaceholderRenderArray; + /** + * The corresponding expected embedded HTML response. + * * @var string */ public $embeddedHtmlResponse; - function __construct(array $render_array, $placeholder, array $placeholder_render_array) { + public function __construct(array $render_array, $placeholder, array $placeholder_render_array) { $this->renderArray = $render_array; $this->placeholder = $placeholder; $this->placeholderRenderArray = $placeholder_render_array; diff --git a/src/Tests/BigPipeTest.php b/src/Tests/BigPipeTest.php index a852fbb..b30d27b 100644 --- a/src/Tests/BigPipeTest.php +++ b/src/Tests/BigPipeTest.php @@ -285,6 +285,9 @@ class BigPipeTest extends WebTestBase { $this->assertEqual($expected_stream_order, array_values($actual_stream_order)); } + /** + * @return \Drupal\big_pipe\Tests\BigPipePlaceholderTestCase[] + */ protected function getTestCases() { // Ensure we can generate CSRF tokens for the current user's session. $session_data = $this->container->get('session_handler.write_safe')->read($this->cookies[$this->getSessionName()]['value']);