function AJAXFrameworkTestCase::testAJAXRender in Drupal 7
Test that ajax_render() returns JavaScript settings generated during the page request.
@todo Add tests to ensure that ajax_render() returns commands for new CSS and JavaScript files to be loaded by the page. See http://drupal.org/node/561858.
File
- modules/
simpletest/ tests/ ajax.test, line 78
Class
- AJAXFrameworkTestCase
- Tests primary Ajax framework functions.
Code
function testAJAXRender() {
$commands = $this
->drupalGetAJAX('ajax-test/render');
// Verify that there is a command to load settings added with
// drupal_add_js().
$expected = array(
'command' => 'settings',
'settings' => array(
'basePath' => base_path(),
'ajax' => 'test',
),
);
$this
->assertCommand($commands, $expected, t('ajax_render() loads settings added with drupal_add_js().'));
// Verify that Ajax settings are loaded for #type 'link'.
$this
->drupalGet('ajax-test/link');
$settings = $this
->drupalGetSettings();
$this
->assertEqual($settings['ajax']['ajax-link']['url'], url('filter/tips'));
$this
->assertEqual($settings['ajax']['ajax-link']['wrapper'], 'block-system-main');
}