Commit b4a8b146 authored by Dries's avatar Dries

- Patch #689738 by c960657: use Save and Delete buttons on path alias editing form.

parent 1f7aa072
......@@ -1327,7 +1327,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
'alias' => $english_path,
'language' => 'en',
);
$this->drupalPost($path, $edit, t('Create new alias'));
$this->drupalPost($path, $edit, t('Save'));
// Create a path alias in new custom language.
$custom_language_path = $this->randomName(8);
......@@ -1336,7 +1336,7 @@ class LocalePathFunctionalTest extends DrupalWebTestCase {
'alias' => $custom_language_path,
'language' => $langcode,
);
$this->drupalPost($path, $edit, t('Create new alias'));
$this->drupalPost($path, $edit, t('Save'));
// Confirm English language path alias works.
$this->drupalGet($english_path);
......
......@@ -121,26 +121,41 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
'#type' => 'value',
'#value' => $path['language']
);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array('class' => array('form-actions')),
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
if ($path['pid']) {
$form['pid'] = array(
'#type' => 'hidden',
'#value' => $path['pid'],
);
$form['submit'] = array(
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Update alias'),
);
}
else {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create new alias'),
'#value' => t('Delete'),
'#submit' => array('path_admin_form_delete_submit'),
);
}
return $form;
}
/**
* Submit function for the 'Delete' button on the URL alias editing form.
*/
function path_admin_form_delete_submit($form, &$form_state) {
$destination = array();
if (isset($_GET['destination'])) {
$destination = drupal_get_destination();
unset($_GET['destination']);
}
$form_state['redirect'] = array('admin/config/search/path/delete/' . $form_state['values']['pid'], array('query' => $destination));
}
/**
* Verify that a URL alias is valid
......@@ -207,7 +222,6 @@ function path_admin_delete_confirm_submit($form, &$form_state) {
}
}
/**
* Return a form to filter URL aliases.
*
......
......@@ -34,7 +34,7 @@ class PathTestCase extends DrupalWebTestCase {
$edit = array();
$edit['source'] = 'node/' . $node1->nid;
$edit['alias'] = $this->randomName(8);
$this->drupalPost('admin/config/search/path/add', $edit, t('Create new alias'));
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
// Visit the system path for the node and confirm a cache entry is
// created.
......@@ -59,7 +59,7 @@ class PathTestCase extends DrupalWebTestCase {
$edit = array();
$edit['source'] = 'node/' . $node1->nid;
$edit['alias'] = $this->randomName(8);
$this->drupalPost('admin/config/search/path/add', $edit, t('Create new alias'));
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
// Confirm that the alias works.
$this->drupalGet($edit['alias']);
......@@ -71,7 +71,7 @@ class PathTestCase extends DrupalWebTestCase {
$previous = $edit['alias'];
$edit['alias'] = $this->randomName(8);
$this->drupalPost('admin/config/search/path/edit/' . $pid, $edit, t('Update alias'));
$this->drupalPost('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
// Confirm that the alias works.
$this->drupalGet($edit['alias']);
......@@ -90,13 +90,14 @@ class PathTestCase extends DrupalWebTestCase {
// Set alias to second test node.
$edit['source'] = 'node/' . $node2->nid;
// leave $edit['alias'] the same
$this->drupalPost('admin/config/search/path/add', $edit, t('Create new alias'));
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
// Confirm no duplicate was created.
$this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])), 'Attempt to move alias was rejected.');
// Delete alias.
$this->drupalPost('admin/config/search/path/delete/' . $pid, array(), t('Confirm'));
$this->drupalPost('admin/config/search/path/edit/' . $pid, array(), t('Delete'));
$this->drupalPost(NULL, array(), t('Confirm'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['alias']);
......
......@@ -165,7 +165,7 @@ class UrlAlterFunctionalTest extends DrupalWebTestCase {
// Test that alias source paths are normalized in the interface.
$edit = array('source' => "user/$name/edit", 'alias' => 'alias/test2');
$this->drupalPost('admin/config/search/path/add', $edit, t('Create new alias'));
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->assertText(t('The alias has been saved.'));
// Test that a path always uses its alias.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment