function HtmxAttributesTest::testHxValidate

Test validate method.

Attributes

#[DataProvider('hxValidateDataProvider')]

File

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

Class

HtmxAttributesTest
Test all attribute-related Htmx public methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public function testHxValidate(?bool $value, string $expected) : void {
  if (is_null($value)) {
    $this->htmx
      ->validate();
  }
  else {
    $this->htmx
      ->validate($value);
  }
  $render = $this->apply();
  $this->assertTrue(isset($render['#attributes']['data-hx-validate']));
  $this->assertEquals($expected, $render['#attributes']['data-hx-validate']);
}

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