core/modules/big_pipe/src/Tests/BigPipeTest.php | 4 ++++ .../big_pipe_test/src/BigPipeTestController.php | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/modules/big_pipe/src/Tests/BigPipeTest.php b/core/modules/big_pipe/src/Tests/BigPipeTest.php index 72685d0..43b364a 100644 --- a/core/modules/big_pipe/src/Tests/BigPipeTest.php +++ b/core/modules/big_pipe/src/Tests/BigPipeTest.php @@ -318,6 +318,8 @@ public function testBigPipeNoSession() { $this->assertIdentical('MISS', $this->drupalGetHeader('X-Drupal-Cache'), 'Page cache miss.'); $this->assertBigPipeResponseHeadersPresent($expectations['cache control visibility'], $expectations['surrogate control directive']); $this->assertNoCacheTag('cache_tag_set_in_lazy_builder'); + $this->assertRaw('This should be marked active'); + $this->assertRaw('This should be marked inactive'); $cases = $this->getTestCases(FALSE); $this->assertBigPipeNoJsPlaceholders([ @@ -347,6 +349,8 @@ public function testBigPipeNoSession() { $this->assertFalse($this->drupalGetHeader('Surrogate-Control'), 'No Surrogate-Control header.'); $this->assertFalse($this->drupalGetHeader('X-Accel-Buffering'), 'No X-Accel-Buffering header.'); $this->assertCacheTag('cache_tag_set_in_lazy_builder'); + $this->assertRaw('This should be marked active'); + $this->assertRaw('This should be marked inactive'); // Clear the Page Cache. Note that we use a cache tag that exists on this diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php index 51ccb1c..35906f2 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php @@ -5,6 +5,7 @@ use Drupal\big_pipe\Render\BigPipeMarkup; use Drupal\big_pipe\Tests\BigPipePlaceholderTestCases; use Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber; +use Drupal\Core\Url; class BigPipeTestController { @@ -52,6 +53,26 @@ public function test() { // 7. Exception: placeholder that causes response filter to throw exception. $build['exception__embedded_response'] = $cases['exception__embedded_response']->renderArray; + // Edge case for no-session (and hence anonymous) responses: active links. + // @see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter + $build['active_link'] = [ + '#type' => 'link', + '#title' => 'This should be marked active', + '#url' => Url::fromRoute('big_pipe_test'), + '#options' => [ + 'set_active_class' => TRUE, + ], + ]; + + $build['inactive_link'] = [ + '#type' => 'link', + '#title' => 'This should be marked inactive', + '#url' => Url::fromRoute(''), + '#options' => [ + 'set_active_class' => TRUE, + ], + ]; + return $build; }