function BigPipeTest::assertCsrfTokenPlaceholderTestCaseData

Asserts that CSRF-token-based test case data is independently correct.

The html_attribute_value_subset case tests a CSRF token link placeholder. This assertion verifies the placeholder hash in the test case matches what RouteProcessorCsrf would actually generate for the route path, so that a wrong route or path in the test data cannot silently pass.

Parameters

\Drupal\big_pipe_test\BigPipePlaceholderTestCase[] $cases: The test cases from BigPipePlaceholderTestCases::cases().

2 calls to BigPipeTest::assertCsrfTokenPlaceholderTestCaseData()
BigPipeTest::testBigPipe in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe-delivered HTML responses when JavaScript is enabled.
BigPipeTest::testBigPipeNoJs in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe-delivered HTML responses when JavaScript is disabled.

File

core/modules/big_pipe/tests/src/Functional/BigPipeTest.php, line 482

Class

BigPipeTest
Tests BigPipe's no-JS detection & response delivery (with and without JS).

Namespace

Drupal\Tests\big_pipe\Functional

Code

protected function assertCsrfTokenPlaceholderTestCaseData(array $cases) : void {
  $case = $cases['html_attribute_value_subset'];
  // The placeholder for an HTML attribute value subset is just the hash
  // string itself (not wrapped in HTML). Verify it equals what Crypt would
  // produce for the expected route path.
  $this->assertSame(Crypt::hashBase64('admin/appearance/default'), $case->placeholder);
  // Verify the no-JS placeholder string contains the same hash.
  $this->assertStringContainsString($case->placeholder, $case->bigPipeNoJsPlaceholder);
  // Verify the embedded HTML response is the actual CSRF token for the path.
  $this->assertSame($this->container
    ->get('csrf_token')
    ->get('admin/appearance/default'), $case->embeddedHtmlResponse);
}

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