Commit 25c18d5d authored by webchick's avatar webchick

#403526 by pwolanin: Fix PDO exception when enabling a menu link.

parent f13422b6
......@@ -149,7 +149,8 @@ function menu_overview_form_submit($form, &$form_state) {
}
// Hidden is a special case, the value needs to be reversed.
if ($element['hidden']['#value'] != $element['hidden']['#default_value']) {
$element['#item']['hidden'] = !$element['hidden']['#value'];
// Convert to integer rather than boolean due to PDO cast to string.
$element['#item']['hidden'] = $element['hidden']['#value'] ? 0 : 1;
$updated_items[$mlid] = $element['#item'];
}
}
......
......@@ -154,6 +154,19 @@ class MenuTestCase extends DrupalWebTestCase {
// Toggle menu links.
$this->toggleMenuLink($item1);
$this->toggleMenuLink($item2);
// Enable a link via the overview form.
$this->disableMenuLink($item1);
$edit = array();
// Note in the UI the 'mlid:x[hidden]' form element maps to enabled, or
// NOT hidden.
$edit['mlid:' . $item1['mlid'] . '[hidden]'] = TRUE;
$this->drupalPost('admin/build/menu-customize/'. $item1['menu_name'], $edit, t('Save configuration'));
// Verify in the database.
$hidden = db_result(db_query("SELECT hidden FROM {menu_links} WHERE mlid = :mlid", array('mlid' => $item1['mlid'])));
$this->assertEqual($hidden, 0, t('Link is not hidden in the database table when enabled via the overview form'));
// Save menu links for later tests.
$this->items[] = $item1;
......@@ -331,35 +344,57 @@ class MenuTestCase extends DrupalWebTestCase {
/**
* Alternately disable and enable a menu link.
*
* @param array $item Menu link.
* @param $item
* Menu link.
*/
function toggleMenuLink($item) {
$mlid = $item['mlid'];
$title = $item['link_title'];
$this->disableMenuLink($item);
$edit = array();
// Verify menu link is absent.
$this->drupalGet('');
$this->assertNoText($item['link_title'], 'Menu link was not displayed');
$this->enableMenuLink($item);
// Verify menu link is displayed.
$this->drupalGet('');
$this->assertText($item['link_title'], 'Menu link was displayed');
}
/**
* Disable a menu link.
*
* @param $item
* Menu link.
*/
function disableMenuLink($item) {
$mlid = $item['mlid'];
$edit['menu[enabled]'] = FALSE;
$this->drupalPost("admin/build/menu/item/$mlid/edit", $edit, t('Save'));
$this->assertResponse(200);
// Unlike most other modules, there is no confirmation message displayed.
// Verify menu link is absent.
$this->drupalGet('');
$this->assertNoText($title, 'Menu link was not displayed');
// Unlike most other modules, there is no confirmation message displayed.
// Verify in the database.
$hidden = db_result(db_query("SELECT hidden FROM {menu_links} WHERE mlid = :mlid", array('mlid' => $mlid)));
$this->assertEqual($hidden, 1, t('Link is hidden in the database table'));
}
// Edit menu link.
/**
* Enable a menu link.
*
* @param $item
* Menu link.
*/
function enableMenuLink($item) {
$mlid = $item['mlid'];
$edit['menu[enabled]'] = TRUE;
$this->drupalPost("admin/build/menu/item/$mlid/edit", $edit, t('Save'));
$this->assertResponse(200);
// Verify menu link is displayed.
$this->drupalGet('');
$this->assertText($title, 'Menu link was displayed');
// Verify in the database.
$hidden = db_result(db_query("SELECT hidden FROM {menu_links} WHERE mlid = :mlid", array('mlid' => $mlid)));
$this->assertEqual($hidden, 0, t('Link is not hidden in the database table'));
}
/**
* Get standard menu link.
*
*/
private function getStandardMenuLink() {
// Retrieve menu link id of the Log out menu link, which will always be on the front page.
......
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