function HtmxAttributesTest::testHxVals

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Htmx/HtmxAttributesTest.php \Drupal\Tests\Core\Htmx\HtmxAttributesTest::testHxVals()

Test vals method.

File

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

Class

HtmxAttributesTest
Test all attribute-related Htmx public methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public function testHxVals() : void {
  $values = [
    'myValue' => 'My Value',
  ];
  $this->htmx
    ->vals($values);
  $render = $this->apply();
  $this->assertTrue(isset($render['#attributes']['data-hx-vals']));
  $this->assertEquals('{"myValue":"My Value"}', $render['#attributes']['data-hx-vals']);
}

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