function PageRenderTest::testHtmlRendererAttachmentsRenderContext

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Common/PageRenderTest.php \Drupal\Tests\system\Kernel\Common\PageRenderTest::testHtmlRendererAttachmentsRenderContext()
  2. 11.x core/modules/system/tests/src/Kernel/Common/PageRenderTest.php \Drupal\Tests\system\Kernel\Common\PageRenderTest::testHtmlRendererAttachmentsRenderContext()

Tests HtmlRenderer::invokePageAttachmentHooks in a render context.

File

core/modules/system/tests/src/Kernel/Common/PageRenderTest.php, line 87

Class

PageRenderTest
Test page rendering hooks.

Namespace

Drupal\Tests\system\Kernel\Common

Code

public function testHtmlRendererAttachmentsRenderContext() : void {
    $this->enableModules([
        'common_test',
        'system',
    ]);
    \Drupal::state()->set('common_test.hook_page_attachments.render_url', TRUE);
    $uri = '/common/attachments-test';
    $request = new Request([], [], [], [], [], [
        'REQUEST_URI' => $uri,
        'SCRIPT_NAME' => $uri,
    ]);
    $response = \Drupal::service('http_kernel')->handle($request);
    $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}

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