Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
286
Merge Requests
286
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
25c18d5d
Commit
25c18d5d
authored
Mar 16, 2009
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#403526
by pwolanin: Fix PDO exception when enabling a menu link.
parent
f13422b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
16 deletions
+52
-16
modules/menu/menu.admin.inc
modules/menu/menu.admin.inc
+2
-1
modules/menu/menu.test
modules/menu/menu.test
+50
-15
No files found.
modules/menu/menu.admin.inc
View file @
25c18d5d
...
...
@@ -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'
];
}
}
...
...
modules/menu/menu.test
View file @
25c18d5d
...
...
@@ -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
->
assert
Text
(
$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
->
assert
Equal
(
$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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment