function AjaxCommandsUnitTest::testReplaceCommand

Tests that ReplaceCommand objects can be constructed and rendered.

File

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

Class

AjaxCommandsUnitTest
Tests for all AJAX Commands.

Namespace

Drupal\system\Tests\Ajax

Code

function testReplaceCommand() {
  $command = new ReplaceCommand('#page-title', '<p>New Text!</p>', array(
    'my-setting' => 'setting',
  ));
  $expected = array(
    'command' => 'insert',
    'method' => 'replaceWith',
    'selector' => '#page-title',
    'data' => '<p>New Text!</p>',
    'settings' => array(
      'my-setting' => 'setting',
    ),
  );
  $this
    ->assertEqual($command
    ->render(), $expected, 'ReplaceCommand::render() returns a proper array.');
}