function AjaxCommandsTest::testDataCommand

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testDataCommand()
  2. 10 core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testDataCommand()
  3. 11.x core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php \Drupal\Tests\Core\Ajax\AjaxCommandsTest::testDataCommand()

@covers \Drupal\Core\Ajax\DataCommand

File

core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php, line 210

Class

AjaxCommandsTest
Test coverage for various classes in the \Drupal\Core\Ajax namespace.

Namespace

Drupal\Tests\Core\Ajax

Code

public function testDataCommand() {
    $command = new DataCommand('#page-title', 'my-data', [
        'key' => 'value',
    ]);
    $expected = [
        'command' => 'data',
        'selector' => '#page-title',
        'name' => 'my-data',
        'value' => [
            'key' => 'value',
        ],
    ];
    $this->assertEquals($expected, $command->render());
}

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