Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.49
diff -u -p -r1.49 node.test
--- modules/node/node.test	16 Oct 2009 23:48:37 -0000	1.49
+++ modules/node/node.test	22 Oct 2009 15:51:50 -0000
@@ -1042,3 +1042,133 @@ class NodeTitleTestCase extends DrupalWe
     $this->assertEqual(current($this->xpath($xpath)), $node->title[FIELD_LANGUAGE_NONE][0]['value'], 'Node preview title is equal to node title.', 'Node');
   }
 }
+
+/**
+ * Test nodes single/multiple deletion functionality.
+ */
+class NodeDeleteTestCase extends DrupalWebTestCase {
+  protected $admin_user;
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Nodes deletion',
+      'description' => 'Test node single/multiple deletion functionality.',
+      'group' => 'Node'
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+    $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'edit any article content', 'edit any page content', 'delete any article content', 'delete any page content'));
+    $this->drupalLogin($this->admin_user);
+  }
+    
+  /**
+  *  Create one node and test if the node title has the correct value.
+  */
+  function testNodeDelete() {
+    // Create a page.
+    $edit = array();
+    $langcode = FIELD_LANGUAGE_NONE;
+    $edit["title[$langcode][0][value]"] = $this->randomName(8);
+    $edit["body[$langcode][0][value]"] = $this->randomName(16);
+    $this->drupalPost('node/add/page', $edit, t('Save'));
+
+    // Check that the page has been created.
+    $page = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+    $this->assertTrue($page, t('Page found in database.'));
+    
+    // Delete the previous page.
+    $this->drupalPost('node/' . $page->nid . '/delete', array(), t('Delete'));
+    $page = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+    // Check that the page has been deleted.
+    $this->assertFalse($page, t('Page correctly deleted.'));
+    
+    // Create an article.
+    $edit = array();
+    $langcode = FIELD_LANGUAGE_NONE;
+    $edit["title[$langcode][0][value]"] = $this->randomName(8);
+    $edit["body[$langcode][0][value]"] = $this->randomName(16);
+    $this->drupalPost('node/add/article', $edit, t('Save'));
+
+    // Check that the article has been created.
+    $article = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+    $this->assertTrue($article, t('Article found in database.'));
+    
+    // Delete the previous article.
+    $this->drupalPost('node/' . $article->nid . '/delete', array(), t('Delete'));
+    $article = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+    // Check that the page has been deleted.
+    $this->assertFalse($article, t('Article correctly deleted.'));
+    
+    $settings = array(
+      'operation' => 'delete',
+    );
+    
+    for ($i = 0; $i < 5; $i++) {
+      $edit = array();
+      $langcode = FIELD_LANGUAGE_NONE;
+      $edit["title[$langcode][0][value]"] = $this->randomName(8);
+      $edit["body[$langcode][0][value]"] = $this->randomName(16);
+      $this->drupalPost('node/add/page', $edit, t('Save'));
+      $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+      $settings['nodes[' . $node->nid . ']'] = $node->nid;
+    }
+    
+    $count = db_select('node')
+      ->condition('type', 'page')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+      
+    // The five pages have been created.
+    $this->assertEqual($count, 5, 'Found five pages in database.');
+    
+    for ($i = 0; $i < 5; $i++) {
+      $edit = array();
+      $langcode = FIELD_LANGUAGE_NONE;
+      $edit["title[$langcode][0][value]"] = $this->randomName(8);
+      $edit["body[$langcode][0][value]"] = $this->randomName(16);
+      $this->drupalPost('node/add/article', $edit, t('Save'));
+      $node = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
+      $settings['nodes[' . $node->nid . ']'] = $node->nid;
+    }
+    
+    $count = db_select('node')
+      ->condition('type', 'article')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+      
+    // The five pages have been created.
+    $this->assertEqual($count, 5, 'Found five articles in database.');
+    $this->drupalPost('admin/content', $settings, t('Update'));
+    $this->drupalPost(NULL, NULL, t('Delete'));
+    
+    $count = db_select('node')
+      ->condition('type', 'page')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+      
+    // The five pages have been deleted.
+    $this->assertEqual($count, 0, 'Deleted all five pages.');
+    
+    $count = db_select('node')
+      ->condition('type', 'article')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+      
+    // The five pages have been deleted.
+    $this->assertEqual($count, 0, 'Deleted all five articles.');
+    
+    $count = db_select('node')
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+      
+    // The five pages have been deleted.
+    $this->assertEqual($count, 0, 'Deleted all nodes.');
+  }
+}
