1 ajax.test AJAXFrameworkTestCase::testAJAXRenderError()

Test behavior of ajax_render_error().

File

core/modules/simpletest/tests/ajax.test, line 93
Ajax Tests.

Class

AJAXFrameworkTestCase
Tests primary Ajax framework functions.

Code

function testAJAXRenderError() {
  // Verify default error message.
  $commands = $this->backdropGetAJAX('ajax-test/render-error');
  $expected = array(
    'command' => 'alert',
    'text' => t('An error occurred while handling the request: The server received invalid input.'),
  );
  $this->assertCommand($commands, $expected, t('ajax_render_error() invokes alert command.'));

  // Verify custom error message.
  $edit = array(
    'message' => 'Custom error message.',
  );
  $commands = $this->backdropGetAJAX('ajax-test/render-error', array('query' => $edit));
  $expected = array(
    'command' => 'alert',
    'text' => $edit['message'],
  );
  $this->assertCommand($commands, $expected, t('Custom error message is output.'));
}