function HtmxUtilitiesTest::testApplyTo
Test ::applyTo with defaults.
File
-
core/
tests/ Drupal/ Tests/ Core/ Htmx/ HtmxUtilitiesTest.php, line 91
Class
- HtmxUtilitiesTest
- Test all Htmx public utility methods.
Namespace
Drupal\Tests\Core\HtmxCode
public function testApplyTo() : void {
$render = [
'#attributes' => [
'plum' => 'strawberry',
],
'#attached' => [
'http_header' => [
[
'melon',
'watermelon',
TRUE,
],
],
],
];
$this->htmx
->applyTo($render);
$this->assertTrue(isset($render['#attributes']));
$this->assertTrue(isset($render['#attached']['http_header']));
$this->assertTrue(isset($render['#attached']['library']));
// We added 2 attributes and 2 headers.
$this->assertEquals(3, count($render['#attributes']));
$this->assertEquals(3, count($render['#attached']['http_header']));
$this->assertEquals([
'core/drupal.htmx',
], $render['#attached']['library']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.