function HtmxAttributesTest::hxOnDataProvider

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

Provides data to self::testHxOn.

Return value

array<int, string[]> Array of event, expected.

File

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

Class

HtmxAttributesTest
Test all attribute-related Htmx public methods.

Namespace

Drupal\Tests\Core\Htmx

Code

public static function hxOnDataProvider() : array {
  return [
    [
      'simple',
      'someAction(this)',
      'data-hx-on:simple',
      'someAction(this)',
    ],
    [
      '::before:request',
      'someAction(event)',
      'data-hx-on::before:request',
      'someAction(event)',
    ],
    [
      [
        'singleEvent' => 'someAction()',
      ],
      '',
      'data-hx-on',
      'singleEvent -> someAction()',
    ],
    [
      [
        'load' => 'this.showModal()',
        'click from:self, closeDialog from:body' => 'this.close()',
      ],
      '',
      'data-hx-on',
      'load -> this.showModal(); click from:self, closeDialog from:body -> this.close()',
    ],
    [
      [
        'close' => "this.remove(); log('dialog removed')",
      ],
      '',
      'data-hx-on',
      "close -> this.remove(); log('dialog removed')",
    ],
  ];
}

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