function AssetOptimizationTest::assertInvalidAggregates

Same name and namespace in other branches
  1. 10 core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php \Drupal\FunctionalTests\Asset\AssetOptimizationTest::assertInvalidAggregates()

Asserts the aggregate when it is invalid.

Parameters

string $url: The source URL.

Throws

\Behat\Mink\Exception\ExpectationException

1 call to AssetOptimizationTest::assertInvalidAggregates()
AssetOptimizationTest::doTestAggregation in core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php
Helper to test aggregate file URLs.

File

core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php, line 162

Class

AssetOptimizationTest
Tests asset aggregation.

Namespace

Drupal\FunctionalTests\Asset

Code

protected function assertInvalidAggregates(string $url) : void {
    $url = $this->getAbsoluteUrl($url);
    // Not every script or style on a page is aggregated.
    if (!str_contains($url, $this->fileAssetsPath)) {
        return;
    }
    $session = $this->getSession();
    $session->visit($this->replaceGroupDelta($url));
    $this->assertSession()
        ->statusCodeEquals(200);
    $session->visit($this->omitTheme($url));
    $this->assertSession()
        ->statusCodeEquals(400);
    $session->visit($this->omitInclude($url));
    $this->assertSession()
        ->statusCodeEquals(400);
    $session->visit($this->invalidInclude($url));
    $this->assertSession()
        ->statusCodeEquals(400);
    $session->visit($this->invalidExclude($url));
    $this->assertSession()
        ->statusCodeEquals(400);
    $session->visit($this->replaceFileNamePrefix($url));
    $this->assertSession()
        ->statusCodeEquals(400);
    $session->visit($this->setInvalidLibrary($url));
    $this->assertSession()
        ->statusCodeEquals(200);
    $session->visit($this->replaceGroupHash($url));
    $this->assertSession()
        ->statusCodeEquals(200);
    $headers = $session->getResponseHeaders();
    $this->assertEquals([
        'no-store, private',
    ], $headers['Cache-Control']);
    // And again to confirm it's not cached on disk.
    $session->visit($this->replaceGroupHash($url));
    $this->assertSession()
        ->statusCodeEquals(200);
    $headers = $session->getResponseHeaders();
    $this->assertEquals([
        'no-store, private',
    ], $headers['Cache-Control']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.