function HtmxRendererTest::testWrapperFormat

Test triggering the renderer with _wrapper_format.

File

core/tests/Drupal/KernelTests/Core/Htmx/HtmxRendererTest.php, line 67

Class

HtmxRendererTest
Verifies HtmxRenderer.

Namespace

Drupal\KernelTests\Core\Htmx

Code

public function testWrapperFormat() : void {
  // Verify the "Powered by" block is rendered on a standard page.
  $url = Url::fromRoute('test_htmx.attachments.replace');
  $request = Request::create($url->toString());
  $response = $this->httpKernel
    ->handle($request);
  $this->assertEquals(200, $response->getStatusCode());
  $this->assertStringContainsString('Powered by', $response->getContent());
  // Verify the body contains only the main content when using the new
  // wrapper format.
  $options = [
    'query' => [
      MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_htmx',
    ],
  ];
  $url = Url::fromRoute('test_htmx.attachments.replace', [], $options);
  $this->assertHtmxResponseContent($url);
}

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