function HtmxAttributesTest::testHxConfig

Test config method.

File

core/tests/Drupal/Tests/Core/Htmx/HtmxAttributesTest.php, line 227

Class

HtmxAttributesTest
Test all attribute-related Htmx public methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public function testHxConfig() : void {
  $values = [
    'timeout' => 100,
    'credentials' => 'include',
  ];
  $this->htmx
    ->config($values);
  $render = $this->apply();
  $this->assertTrue(isset($render['#attributes']['data-hx-config']));
  $this->assertEquals('{"timeout":100,"credentials":"include"}', $render['#attributes']['data-hx-config']);
}

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