security update core+modules
This commit is contained in:
@@ -293,7 +293,7 @@ class AJAXCommandsTestCase extends AJAXTestCase {
|
||||
$this->assertCommand($commands, $expected, "'changed' AJAX command (with asterisk) issued with correct selector");
|
||||
|
||||
// Tests the 'css' command.
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("Set the the '#box' div to be blue.")));
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("Set the '#box' div to be blue.")));
|
||||
$expected = array(
|
||||
'command' => 'css',
|
||||
'selector' => '#css_div',
|
||||
@@ -368,6 +368,14 @@ class AJAXCommandsTestCase extends AJAXTestCase {
|
||||
'settings' => array('ajax_forms_test' => array('foo' => 42)),
|
||||
);
|
||||
$this->assertCommand($commands, $expected, "'settings' AJAX command issued with correct data");
|
||||
|
||||
// Tests the 'add_css' command.
|
||||
$commands = $this->drupalPostAJAX($form_path, $edit, array('op' => t("AJAX 'add_css' command")));
|
||||
$expected = array(
|
||||
'command' => 'add_css',
|
||||
'data' => 'my/file.css',
|
||||
);
|
||||
$this->assertCommand($commands, $expected, "'add_css' AJAX command issued with correct data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,6 +505,85 @@ class AJAXMultiFormTestCase extends AJAXTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Ajax forms when page caching for anonymous users is turned on.
|
||||
*/
|
||||
class AJAXFormPageCacheTestCase extends AJAXTestCase {
|
||||
protected $profile = 'testing';
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'AJAX forms on cached pages',
|
||||
'description' => 'Tests that AJAX forms work properly for anonymous users on cached pages.',
|
||||
'group' => 'AJAX',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
variable_set('cache', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the build id of the current form.
|
||||
*/
|
||||
protected function getFormBuildId() {
|
||||
$build_id_fields = $this->xpath('//input[@name="form_build_id"]');
|
||||
$this->assertEqual(count($build_id_fields), 1, 'One form build id field on the page');
|
||||
return (string) $build_id_fields[0]['value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a simple form, then POST to system/ajax to change to it.
|
||||
*/
|
||||
public function testSimpleAJAXFormValue() {
|
||||
$this->drupalGet('ajax_forms_test_get_form');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
|
||||
$build_id_initial = $this->getFormBuildId();
|
||||
|
||||
$edit = array('select' => 'green');
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, 'select');
|
||||
$build_id_first_ajax = $this->getFormBuildId();
|
||||
$this->assertNotEqual($build_id_initial, $build_id_first_ajax, 'Build id is changed in the simpletest-DOM on first AJAX submission');
|
||||
$expected = array(
|
||||
'command' => 'updateBuildId',
|
||||
'old' => $build_id_initial,
|
||||
'new' => $build_id_first_ajax,
|
||||
);
|
||||
$this->assertCommand($commands, $expected, 'Build id change command issued on first AJAX submission');
|
||||
|
||||
$edit = array('select' => 'red');
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, 'select');
|
||||
$build_id_second_ajax = $this->getFormBuildId();
|
||||
$this->assertEqual($build_id_first_ajax, $build_id_second_ajax, 'Build id remains the same on subsequent AJAX submissions');
|
||||
|
||||
// Repeat the test sequence but this time with a page loaded from the cache.
|
||||
$this->drupalGet('ajax_forms_test_get_form');
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
|
||||
$build_id_from_cache_initial = $this->getFormBuildId();
|
||||
$this->assertEqual($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request');
|
||||
|
||||
$edit = array('select' => 'green');
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, 'select');
|
||||
$build_id_from_cache_first_ajax = $this->getFormBuildId();
|
||||
$this->assertNotEqual($build_id_from_cache_initial, $build_id_from_cache_first_ajax, 'Build id is changed in the simpletest-DOM on first AJAX submission');
|
||||
$this->assertNotEqual($build_id_first_ajax, $build_id_from_cache_first_ajax, 'Build id from first user is not reused');
|
||||
$expected = array(
|
||||
'command' => 'updateBuildId',
|
||||
'old' => $build_id_from_cache_initial,
|
||||
'new' => $build_id_from_cache_first_ajax,
|
||||
);
|
||||
$this->assertCommand($commands, $expected, 'Build id change command issued on first AJAX submission');
|
||||
|
||||
$edit = array('select' => 'red');
|
||||
$commands = $this->drupalPostAJAX(NULL, $edit, 'select');
|
||||
$build_id_from_cache_second_ajax = $this->getFormBuildId();
|
||||
$this->assertEqual($build_id_from_cache_first_ajax, $build_id_from_cache_second_ajax, 'Build id remains the same on subsequent AJAX submissions');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Miscellaneous Ajax tests using ajax_test module.
|
||||
*/
|
||||
@@ -524,7 +611,7 @@ class AJAXElementValidation extends AJAXTestCase {
|
||||
// Post with 'drivertext' as the triggering element.
|
||||
$post_result = $this->drupalPostAJAX('ajax_validation_test', $edit, 'drivertext');
|
||||
// Look for a validation failure in the resultant JSON.
|
||||
$this->assertNoText(t('Error message'), t("No error message in resultant JSON"));
|
||||
$this->assertText('ajax_forms_test_validation_form_callback invoked', t('The correct callback was invoked'));
|
||||
$this->assertNoText(t('Error message'), "No error message in resultant JSON");
|
||||
$this->assertText('ajax_forms_test_validation_form_callback invoked', 'The correct callback was invoked');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user