Commit 85a807de authored by webchick's avatar webchick

Issue #1175700 by caiovlp, swentel, ldweeks: Fixed set_name() in shortcut_set_save() doesn't work.

parent cd71e5cc
......@@ -153,4 +153,16 @@ function testShortcutSetDeleteDefault() {
$this->drupalGet('admin/config/user-interface/shortcut/' . SHORTCUT_DEFAULT_SET_NAME . '/delete');
$this->assertResponse(403);
}
/**
* Tests creating a new shortcut set with a defined set name.
*/
function testShortcutSetCreateWithSetName() {
$random_name = $this->randomName(10);
$new_set = $this->generateShortcutSet($random_name, TRUE, $random_name);
$sets = shortcut_sets();
$this->assertTrue(isset($sets[$random_name]), 'Successfully created a shortcut set with a defined set name.');
$this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts');
$this->assertText($new_set->title, 'Generated shortcut set was listed as a choice on the user account page.');
}
}
......@@ -67,9 +67,15 @@ function setUp() {
/**
* Creates a generic shortcut set.
*/
function generateShortcutSet($title = '', $default_links = TRUE) {
function generateShortcutSet($title = '', $default_links = TRUE, $set_name = '') {
$set = new stdClass();
$set->title = empty($title) ? $this->randomName(10) : $title;
// Set name is generated automatically if not set.
if (!empty($set_name)) {
$set->set_name = $set_name;
}
if ($default_links) {
$set->links = array();
$set->links[] = $this->generateShortcutLink('node/add');
......
......@@ -351,7 +351,10 @@ function shortcut_set_load($set_name) {
function shortcut_set_save(&$shortcut_set) {
// First save the shortcut set itself.
if (isset($shortcut_set->set_name)) {
$return = drupal_write_record('shortcut_set', $shortcut_set, 'set_name');
$return = db_merge('shortcut_set')
->key(array('set_name' => $shortcut_set->set_name))
->fields(array('title' => $shortcut_set->title))
->execute();
}
else {
$shortcut_set->set_name = shortcut_set_get_unique_name();
......
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