function AjaxCommandsUnitTest::testOpenModalDialogCommand

Tests that OpenModalDialogCommand objects can be constructed and rendered.

File

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

Class

AjaxCommandsUnitTest
Tests for all AJAX Commands.

Namespace

Drupal\system\Tests\Ajax

Code

function testOpenModalDialogCommand() {
  $command = new OpenModalDialogCommand('Title', '<p>Text!</p>', array(
    'url' => 'example',
    'width' => 500,
  ));
  $expected = array(
    'command' => 'openDialog',
    'selector' => '#drupal-modal',
    'settings' => NULL,
    'data' => '<p>Text!</p>',
    'dialogOptions' => array(
      'url' => 'example',
      'width' => 500,
      'title' => 'Title',
      'modal' => TRUE,
    ),
  );
  $this
    ->assertEqual($command
    ->render(), $expected, 'OpenModalDialogCommand::render() returns a proper array.');
}