function HtmxRequestInfoTest::testGetHtmxTarget

Tests the getHtmxTarget method.

File

core/tests/Drupal/Tests/Core/Htmx/HtmxRequestInfoTest.php, line 98

Class

HtmxRequestInfoTest
Test all HtmxRequestInfoTrait methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public function testGetHtmxTarget() : void {
  // Test with the header not present.
  $this->assertEquals('', $this->getHtmxTarget());
  // Test with the header present.
  $this->request->headers
    ->set('HX-Target', 'submit-button');
  $this->assertEquals('submit-button', $this->getHtmxTarget());
}

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