#601398 follow-up by andypost, rfay, and sun: Allow drupLPost to target specific form HTML ID for multiple similar forms.
parent
cb112e9a34
commit
be6d3c8bb6
|
@ -1600,12 +1600,15 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
* @param $headers
|
* @param $headers
|
||||||
* An array containing additional HTTP request headers, each formatted as
|
* An array containing additional HTTP request headers, each formatted as
|
||||||
* "name: value".
|
* "name: value".
|
||||||
* @param $form_id
|
* @param $form_html_id
|
||||||
* The optional string identifying the form to be submitted. On some pages
|
* (optional) HTML ID of the form to be submitted. On some pages
|
||||||
* there are many identical forms, so just using the value of the submit
|
* there are many identical forms, so just using the value of the submit
|
||||||
* button is not enough.
|
* button is not enough. For example: 'trigger-node-presave-assign-form'.
|
||||||
|
* Note that this is not the Drupal $form_id, but rather the HTML ID of the
|
||||||
|
* form, which is typically the same thing but with hyphens replacing the
|
||||||
|
* underscores.
|
||||||
*/
|
*/
|
||||||
protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array(), $form_id = NULL) {
|
protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL) {
|
||||||
$submit_matches = FALSE;
|
$submit_matches = FALSE;
|
||||||
$ajax = is_array($submit);
|
$ajax = is_array($submit);
|
||||||
if (isset($path)) {
|
if (isset($path)) {
|
||||||
|
@ -1615,8 +1618,8 @@ class DrupalWebTestCase extends DrupalTestCase {
|
||||||
$edit_save = $edit;
|
$edit_save = $edit;
|
||||||
// Let's iterate over all the forms.
|
// Let's iterate over all the forms.
|
||||||
$xpath = "//form";
|
$xpath = "//form";
|
||||||
if (!empty($form_id)) {
|
if (!empty($form_html_id)) {
|
||||||
$xpath .= "[@id='" . drupal_html_id($form_id) . "']";
|
$xpath .= "[@id='" . $form_html_id . "']";
|
||||||
}
|
}
|
||||||
$forms = $this->xpath($xpath);
|
$forms = $this->xpath($xpath);
|
||||||
foreach ($forms as $form) {
|
foreach ($forms as $form) {
|
||||||
|
|
|
@ -55,18 +55,18 @@ class TriggerContentTestCase extends TriggerWebTestCase {
|
||||||
global $user;
|
global $user;
|
||||||
$content_actions = array('node_publish_action', 'node_unpublish_action', 'node_make_sticky_action', 'node_make_unsticky_action', 'node_promote_action', 'node_unpromote_action');
|
$content_actions = array('node_publish_action', 'node_unpublish_action', 'node_make_sticky_action', 'node_make_unsticky_action', 'node_promote_action', 'node_unpromote_action');
|
||||||
|
|
||||||
|
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||||
|
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
|
||||||
foreach ($content_actions as $action) {
|
foreach ($content_actions as $action) {
|
||||||
$hash = md5($action);
|
$hash = md5($action);
|
||||||
$info = $this->actionInfo($action);
|
$info = $this->actionInfo($action);
|
||||||
|
|
||||||
// Assign an action to a trigger, then pull the trigger, and make sure
|
// Assign an action to a trigger, then pull the trigger, and make sure
|
||||||
// the actions fire.
|
// the actions fire.
|
||||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
|
||||||
$this->drupalLogin($test_user);
|
$this->drupalLogin($test_user);
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'), array(), array(), 'trigger-node-presave-assign-form');
|
||||||
// Create an unpublished node.
|
// Create an unpublished node.
|
||||||
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
|
|
||||||
$this->drupalLogin($web_user);
|
$this->drupalLogin($web_user);
|
||||||
$edit = array();
|
$edit = array();
|
||||||
$langcode = LANGUAGE_NONE;
|
$langcode = LANGUAGE_NONE;
|
||||||
|
@ -83,12 +83,10 @@ class TriggerContentTestCase extends TriggerWebTestCase {
|
||||||
|
|
||||||
// There should be an error when the action is assigned to the trigger
|
// There should be an error when the action is assigned to the trigger
|
||||||
// twice.
|
// twice.
|
||||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
|
||||||
$this->drupalLogin($test_user);
|
$this->drupalLogin($test_user);
|
||||||
|
// This action already assigned in this test.
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'), array(), array(), 'trigger-node-presave-assign-form');
|
||||||
$edit = array('aid' => $hash);
|
|
||||||
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
|
|
||||||
$this->assertRaw(t('The action you chose is already assigned to that trigger.'), t('Check to make sure an error occurs when assigning an action to a trigger twice.'));
|
$this->assertRaw(t('The action you chose is already assigned to that trigger.'), t('Check to make sure an error occurs when assigning an action to a trigger twice.'));
|
||||||
|
|
||||||
// The action should be able to be unassigned from a trigger.
|
// The action should be able to be unassigned from a trigger.
|
||||||
|
@ -202,7 +200,7 @@ class TriggerCronTestCase extends TriggerWebTestCase {
|
||||||
|
|
||||||
// Assign a non-configurable action to the cron run trigger.
|
// Assign a non-configurable action to the cron run trigger.
|
||||||
$edit = array('aid' => md5('trigger_test_system_cron_action'));
|
$edit = array('aid' => md5('trigger_test_system_cron_action'));
|
||||||
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'), array(), array(), 'trigger-cron-assign-form');
|
||||||
|
|
||||||
// Assign a configurable action to the cron trigger.
|
// Assign a configurable action to the cron trigger.
|
||||||
$action_label = $this->randomName();
|
$action_label = $this->randomName();
|
||||||
|
@ -214,7 +212,7 @@ class TriggerCronTestCase extends TriggerWebTestCase {
|
||||||
// $aid is likely 3 but if we add more uses for the sequences table in
|
// $aid is likely 3 but if we add more uses for the sequences table in
|
||||||
// core it might break, so it is easier to get the value from the database.
|
// core it might break, so it is easier to get the value from the database.
|
||||||
$edit = array('aid' => md5($aid));
|
$edit = array('aid' => md5($aid));
|
||||||
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'), array(), array(), 'trigger-cron-assign-form');
|
||||||
|
|
||||||
// Add a second configurable action to the cron trigger.
|
// Add a second configurable action to the cron trigger.
|
||||||
$action_label = $this->randomName();
|
$action_label = $this->randomName();
|
||||||
|
@ -224,7 +222,7 @@ class TriggerCronTestCase extends TriggerWebTestCase {
|
||||||
);
|
);
|
||||||
$aid = $this->configureAdvancedAction('trigger_test_system_cron_conf_action', $edit);
|
$aid = $this->configureAdvancedAction('trigger_test_system_cron_conf_action', $edit);
|
||||||
$edit = array('aid' => md5($aid));
|
$edit = array('aid' => md5($aid));
|
||||||
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'), array(), array(), 'trigger-cron-assign-form');
|
||||||
|
|
||||||
// Force a cron run.
|
// Force a cron run.
|
||||||
$this->cronRun();
|
$this->cronRun();
|
||||||
|
@ -268,7 +266,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
||||||
$action_id = 'trigger_test_generic_action';
|
$action_id = 'trigger_test_generic_action';
|
||||||
$hash = md5($action_id);
|
$hash = md5($action_id);
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'), array(), array(), 'trigger-user-insert-assign-form');
|
||||||
|
|
||||||
// Set action variable to FALSE.
|
// Set action variable to FALSE.
|
||||||
variable_set( $action_id, FALSE );
|
variable_set( $action_id, FALSE );
|
||||||
|
@ -302,7 +300,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
||||||
// Configure an advanced action that we can assign.
|
// Configure an advanced action that we can assign.
|
||||||
$aid = $this->configureAdvancedAction('system_message_action', $action_edit);
|
$aid = $this->configureAdvancedAction('system_message_action', $action_edit);
|
||||||
$edit = array('aid' => md5($aid));
|
$edit = array('aid' => md5($aid));
|
||||||
$this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'), array(), array(), 'trigger_user_login_assign_form');
|
$this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'), array(), array(), 'trigger-user-login-assign-form');
|
||||||
|
|
||||||
// Verify that the action has been assigned to the correct hook.
|
// Verify that the action has been assigned to the correct hook.
|
||||||
$actions = trigger_get_assigned_actions('user_login');
|
$actions = trigger_get_assigned_actions('user_login');
|
||||||
|
@ -325,7 +323,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
||||||
$action_id = 'trigger_test_generic_action';
|
$action_id = 'trigger_test_generic_action';
|
||||||
$hash = md5($action_id);
|
$hash = md5($action_id);
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/comment', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/comment', $edit, t('Assign'), array(), array(), 'trigger-comment-insert-assign-form');
|
||||||
|
|
||||||
// Set action variable to FALSE.
|
// Set action variable to FALSE.
|
||||||
variable_set($action_id, FALSE);
|
variable_set($action_id, FALSE);
|
||||||
|
@ -354,7 +352,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
||||||
$action_id = 'trigger_test_generic_action';
|
$action_id = 'trigger_test_generic_action';
|
||||||
$hash = md5($action_id);
|
$hash = md5($action_id);
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/taxonomy', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/taxonomy', $edit, t('Assign'), array(), array(), 'trigger-taxonomy-term-insert-assign-form');
|
||||||
|
|
||||||
// Set action variable to FALSE.
|
// Set action variable to FALSE.
|
||||||
variable_set($action_id, FALSE);
|
variable_set($action_id, FALSE);
|
||||||
|
@ -411,7 +409,7 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase {
|
||||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||||
$this->drupalLogin($test_user);
|
$this->drupalLogin($test_user);
|
||||||
$edit = array('aid' => $hash);
|
$edit = array('aid' => $hash);
|
||||||
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
|
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'), array(), array(), 'trigger-node-presave-assign-form');
|
||||||
|
|
||||||
// Create an unpublished node.
|
// Create an unpublished node.
|
||||||
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'access content', 'administer nodes'));
|
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'access content', 'administer nodes'));
|
||||||
|
|
Loading…
Reference in New Issue