#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
|
||||
* An array containing additional HTTP request headers, each formatted as
|
||||
* "name: value".
|
||||
* @param $form_id
|
||||
* The optional string identifying the form to be submitted. On some pages
|
||||
* @param $form_html_id
|
||||
* (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
|
||||
* 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;
|
||||
$ajax = is_array($submit);
|
||||
if (isset($path)) {
|
||||
|
@ -1615,8 +1618,8 @@ class DrupalWebTestCase extends DrupalTestCase {
|
|||
$edit_save = $edit;
|
||||
// Let's iterate over all the forms.
|
||||
$xpath = "//form";
|
||||
if (!empty($form_id)) {
|
||||
$xpath .= "[@id='" . drupal_html_id($form_id) . "']";
|
||||
if (!empty($form_html_id)) {
|
||||
$xpath .= "[@id='" . $form_html_id . "']";
|
||||
}
|
||||
$forms = $this->xpath($xpath);
|
||||
foreach ($forms as $form) {
|
||||
|
|
|
@ -55,18 +55,18 @@ class TriggerContentTestCase extends TriggerWebTestCase {
|
|||
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');
|
||||
|
||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
|
||||
foreach ($content_actions as $action) {
|
||||
$hash = md5($action);
|
||||
$info = $this->actionInfo($action);
|
||||
|
||||
// Assign an action to a trigger, then pull the trigger, and make sure
|
||||
// the actions fire.
|
||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||
$this->drupalLogin($test_user);
|
||||
$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.
|
||||
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
|
||||
$this->drupalLogin($web_user);
|
||||
$edit = array();
|
||||
$langcode = LANGUAGE_NONE;
|
||||
|
@ -83,12 +83,10 @@ class TriggerContentTestCase extends TriggerWebTestCase {
|
|||
|
||||
// There should be an error when the action is assigned to the trigger
|
||||
// twice.
|
||||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||
$this->drupalLogin($test_user);
|
||||
// This action already assigned in this test.
|
||||
$edit = array('aid' => $hash);
|
||||
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
|
||||
$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');
|
||||
$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.
|
||||
|
@ -202,7 +200,7 @@ class TriggerCronTestCase extends TriggerWebTestCase {
|
|||
|
||||
// Assign a non-configurable action to the cron run trigger.
|
||||
$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.
|
||||
$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
|
||||
// core it might break, so it is easier to get the value from the database.
|
||||
$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.
|
||||
$action_label = $this->randomName();
|
||||
|
@ -224,7 +222,7 @@ class TriggerCronTestCase extends TriggerWebTestCase {
|
|||
);
|
||||
$aid = $this->configureAdvancedAction('trigger_test_system_cron_conf_action', $edit);
|
||||
$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.
|
||||
$this->cronRun();
|
||||
|
@ -268,7 +266,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
|||
$action_id = 'trigger_test_generic_action';
|
||||
$hash = md5($action_id);
|
||||
$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.
|
||||
variable_set( $action_id, FALSE );
|
||||
|
@ -302,7 +300,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
|||
// Configure an advanced action that we can assign.
|
||||
$aid = $this->configureAdvancedAction('system_message_action', $action_edit);
|
||||
$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.
|
||||
$actions = trigger_get_assigned_actions('user_login');
|
||||
|
@ -325,7 +323,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
|||
$action_id = 'trigger_test_generic_action';
|
||||
$hash = md5($action_id);
|
||||
$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.
|
||||
variable_set($action_id, FALSE);
|
||||
|
@ -354,7 +352,7 @@ class TriggerOtherTestCase extends TriggerWebTestCase {
|
|||
$action_id = 'trigger_test_generic_action';
|
||||
$hash = md5($action_id);
|
||||
$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.
|
||||
variable_set($action_id, FALSE);
|
||||
|
@ -411,7 +409,7 @@ class TriggerOrphanedActionsTestCase extends DrupalWebTestCase {
|
|||
$test_user = $this->drupalCreateUser(array('administer actions'));
|
||||
$this->drupalLogin($test_user);
|
||||
$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.
|
||||
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'access content', 'administer nodes'));
|
||||
|
|
Loading…
Reference in New Issue