function AJAXFrameworkTestCase::testAJAXRenderError

Test behavior of ajax_render_error().

File

modules/simpletest/tests/ajax.test, line 99

Class

AJAXFrameworkTestCase
Tests primary Ajax framework functions.

Code

function testAJAXRenderError() {
    // Verify default error message.
    $commands = $this->drupalGetAJAX('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->drupalGetAJAX('ajax-test/render-error', array(
        'query' => $edit,
    ));
    $expected = array(
        'command' => 'alert',
        'text' => $edit['message'],
    );
    $this->assertCommand($commands, $expected, t('Custom error message is output.'));
}

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