function WorkspaceQueryParameterNegotiatorTest::testWorkspaceQueryParameter
Same name in other branches
- 10 core/modules/workspaces/tests/src/Kernel/WorkspaceQueryParameterNegotiatorTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceQueryParameterNegotiatorTest::testWorkspaceQueryParameter()
@covers ::getActiveWorkspaceId @dataProvider providerTestWorkspaceQueryParameter
File
-
core/
modules/ workspaces/ tests/ src/ Kernel/ WorkspaceQueryParameterNegotiatorTest.php, line 55
Class
- WorkspaceQueryParameterNegotiatorTest
- Tests the query parameter workspace negotiator.
Namespace
Drupal\Tests\workspaces\KernelCode
public function testWorkspaceQueryParameter(?string $workspace, ?string $token, ?string $negotiated_workspace, bool $has_active_workspace) : void {
// We can't access the settings service in the data provider method, so we
// generate a good token here.
if ($token === 'good_token') {
$hash_salt = $this->container
->get('settings')
->get('hash_salt');
$token = substr(Crypt::hmacBase64($workspace, $hash_salt), 0, 8);
}
$request = \Drupal::request();
$request->query
->set('workspace', $workspace);
$request->query
->set('token', $token);
/** @var \Drupal\workspaces\Negotiator\QueryParameterWorkspaceNegotiator $negotiator */
$negotiator = $this->container
->get('workspaces.negotiator.query_parameter');
$this->assertSame($negotiated_workspace, $negotiator->getActiveWorkspaceId($request));
$this->assertSame($has_active_workspace, \Drupal::service('workspaces.manager')->hasActiveWorkspace());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.