function AjaxCommandsUnitTest::testInvokeCommand

Tests that InvokeCommand objects can be constructed and rendered.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php, line 215
Definition of Drupal\system\Tests\Ajax\AjaxCommandsUnitTest.

Class

AjaxCommandsUnitTest
Tests for all AJAX Commands.

Namespace

Drupal\system\Tests\Ajax

Code

function testInvokeCommand() {
  $command = new InvokeCommand('#page-title', 'myMethod', array(
    'var1',
    'var2',
  ));
  $expected = array(
    'command' => 'invoke',
    'selector' => '#page-title',
    'method' => 'myMethod',
    'args' => array(
      'var1',
      'var2',
    ),
  );
  $this
    ->assertEqual($command
    ->render(), $expected, 'InvokeCommand::render() returns a proper array.');
}