Verified Commit 85e6389a authored by Jess's avatar Jess
Browse files

Issue #3300773 by bradjones1, xjm, catch, andypost, Spokje: Fix failed test on...

Issue #3300773 by bradjones1, xjm, catch, andypost, Spokje: Fix failed test on `symfony/http-foundation` 4.4.44/6.1.3 and later
parent f8e345f6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -15,12 +15,14 @@
 */
class TestControllers {

  const LONG_TEXT = 'This is text long enough to trigger Apache mod_deflate to add a `vary: accept-encoding` header to the response.';

  public function test() {
    return new Response('test');
  }

  public function test1() {
    return new Response('test1');
    return new Response(self::LONG_TEXT);
  }

  public function test2() {
+5 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Language\LanguageInterface;
use Drupal\router_test\TestControllers;
use Drupal\Tests\BrowserTestBase;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Drupal\Core\Url;
@@ -38,7 +39,7 @@ public function testFinishResponseSubscriber() {

    // Confirm that the router can get to a controller.
    $this->drupalGet('router_test/test1');
    $this->assertSession()->pageTextContains('test1');
    $this->assertSession()->pageTextContains(TestControllers::LONG_TEXT);
    $session = $this->getSession();

    // Check expected headers from FinishResponseSubscriber.
@@ -46,7 +47,9 @@ public function testFinishResponseSubscriber() {
    $this->assertSession()->responseHeaderEquals('Content-language', 'en');
    $this->assertSession()->responseHeaderEquals('X-Content-Type-Options', 'nosniff');
    $this->assertSession()->responseHeaderEquals('X-Frame-Options', 'SAMEORIGIN');
    if (strcasecmp($session->getResponseHeader('vary'), 'accept-encoding') !== 0) {
      $this->assertSession()->responseHeaderDoesNotExist('Vary');
    }

    $this->drupalGet('router_test/test2');
    $this->assertSession()->pageTextContains('test2');