diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-24 21:39:40 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-10-24 21:39:40 +0000 |
commit | 09f2d3266bffc78d12d8666e2b3202dedd2cfc8f (patch) | |
tree | 75788ec1fd4c0a5f33de976a012a3ae09e3976b7 /modules | |
parent | 88b1575eb1e61d98fda5c164800cb132a174282c (diff) | |
download | brdo-09f2d3266bffc78d12d8666e2b3202dedd2cfc8f.tar.gz brdo-09f2d3266bffc78d12d8666e2b3202dedd2cfc8f.tar.bz2 |
#609152 by redndahead, bleen18 and jim0203: Ensure node filter page validates that there were rows selected. (with tests)
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node/node.admin.inc | 5 | ||||
-rw-r--r-- | modules/node/node.test | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/modules/node/node.admin.inc b/modules/node/node.admin.inc index fe8636dc9..18e3312f6 100644 --- a/modules/node/node.admin.inc +++ b/modules/node/node.admin.inc @@ -439,6 +439,7 @@ function node_admin_nodes() { '#type' => 'submit', '#value' => t('Update'), '#submit' => array('node_admin_nodes_submit'), + '#validate' => array('node_admin_nodes_validate'), ); $languages = language_list(); @@ -475,8 +476,8 @@ function node_admin_nodes() { * 'Update option' on. */ function node_admin_nodes_validate($form, &$form_state) { - $nodes = array_filter($form_state['values']['nodes']); - if (count($nodes) == 0) { + // Error if there are no items to select. + if (!is_array($form_state['values']['nodes']) || !count(array_filter($form_state['values']['nodes']))) { form_set_error('', t('No items selected.')); } } diff --git a/modules/node/node.test b/modules/node/node.test index 71a39801c..016ce5619 100644 --- a/modules/node/node.test +++ b/modules/node/node.test @@ -967,6 +967,9 @@ class NodeAdminTestCase extends DrupalWebTestCase { * Create 3 nodes and test if they are listed on the node admistration page. */ function testNodeAdmin() { + $this->drupalPost('admin/content', array(), t('Update')); + $this->assertText(t('No items selected.'), t('Clicking update with no nodes displays error message on the node administration listing.')); + $node1 = $this->drupalCreateNode(array('type' => 'article', 'status' => 1)); $node2 = $this->drupalCreateNode(array('type' => 'article', 'status' => 0)); $node3 = $this->drupalCreateNode(array('type' => 'page')); @@ -974,6 +977,9 @@ class NodeAdminTestCase extends DrupalWebTestCase { $this->drupalGet('admin/content'); $this->assertText($node1->title[FIELD_LANGUAGE_NONE][0]['value'], t('Node appears on the node administration listing.')); + $this->drupalPost('admin/content', array(), t('Update')); + $this->assertText(t('No items selected.'), t('Clicking update with no selected nodes displays error message on the node administration listing.')); + // Filter the node listing by status. $edit = array( 'filter' => 'status', |