function HtmxHeadersTest::testRefreshHeader

Test refresh header.

File

core/tests/Drupal/Tests/Core/Htmx/HtmxHeadersTest.php, line 141

Class

HtmxHeadersTest
Test all header-related Htmx public methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public function testRefreshHeader() : void {
  // TRUE case.
  $this->htmx
    ->refreshHeader(TRUE);
  $render = $this->apply();
  $this->assertTrue(isset($render['#attached']['http_header']));
  $this->assertIsArray($render['#attached']['http_header']);
  $value = reset($render['#attached']['http_header']);
  $this->assertEquals('hx-refresh', $value[0]);
  $this->assertEquals('true', $value[1]);
  $this->assertEquals(TRUE, $value[2]);
  // FALSE case.
  $this->htmx
    ->refreshHeader(FALSE);
  $render = $this->apply();
  $this->assertTrue(isset($render['#attached']['http_header']));
  $this->assertIsArray($render['#attached']['http_header']);
  $value = reset($render['#attached']['http_header']);
  $this->assertEquals('hx-refresh', $value[0]);
  $this->assertEquals('false', $value[1]);
  $this->assertEquals(TRUE, $value[2]);
}

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