From cd8fac040052ed6e50d348a11791c1b938ae824c Mon Sep 17 00:00:00 2001
From: Chad Fennell <libsys@gmail.com>
Date: Wed, 9 Mar 2011 14:47:58 -0600
Subject: [PATCH] Issue #1064870: Adding test to demonstrate multiple drupal_form_submit call failure.

---
 modules/node/node.test |   60 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/modules/node/node.test b/modules/node/node.test
index 8a871c0..f3992bf 100644
--- a/modules/node/node.test
+++ b/modules/node/node.test
@@ -500,6 +500,66 @@ class NodeCreationTestCase extends DrupalWebTestCase {
     $node = $this->drupalGetNodeByTitle($edit["title"]);
     $this->assertTrue($node, t('Node found in database.'));
   }
+  
+  /**
+   * Create a "Basic page" node with drupal_form_submit and verify its 
+   * consistency in the database.
+   */
+   function testNodeFormSubmit() {
+       $settings = array(
+         'type' => 'page',
+         'language' => LANGUAGE_NONE, 
+         );
+       $form_state['values'] = array(
+         'body'      => $this->randomName(8),
+         'title'     => $this->randomName(8),
+         'comment'   => 2,
+         'moderate'  => 0,
+         'promote'   => 0,
+         'log'       => '',
+         'status'    => 1,
+         'sticky'    => 0,
+         'op'        => t('Save'),
+         'name'      => $this->loggedInUser->name
+         );    
+       drupal_form_submit('page_node_form', $form_state, (object) $settings);
+     // Check that the node submitted exists in the database.
+     $node = $this->drupalGetNodeByTitle($form_state['values']['title']);
+     $this->assertTrue($node, t('Form Submitted Node found in database.'));
+   }
+   
+  /**
+  * Create multiple "Basic page" nodes with drupal_form_submit and verify their
+  * consistency in the database.
+  */
+  function testNodeFormSubmitMultiple() {
+    for ($x = 0; $x <= 1; $x++) {
+      $settings = array(
+        'type' => 'page',
+        'language' => LANGUAGE_NONE, 
+        );
+      $form_state['values'] = array(
+        'body'      => $this->randomName(8),
+        'title'     => $this->randomName(8),
+        'comment'   => 2,
+        'moderate'  => 0,
+        'promote'   => 0,
+        'log'       => '',
+        'status'    => 1,
+        'sticky'    => 0,
+        'op'        => t('Save'),
+        'name'      => $this->loggedInUser->name
+        );    
+      $titles[$x] = $form_state['values']['title'];
+      drupal_form_submit('page_node_form', $form_state, (object) $settings);
+    }
+    // Check that the first node submitted exists in the database.
+    $node = $this->drupalGetNodeByTitle($titles[0]);
+    $this->assertTrue($node, t('First Multiple Form Submitted Node (!title) found in database.', array('!title' => $titles[0])));
+    // Check that the second node submitted exists in the database.
+    $node = $this->drupalGetNodeByTitle($titles[1]);
+    $this->assertTrue($node, t('Second Multiple Form Submitted Node (!title) found in database.', array('!title' => $titles[1]))); 
+  }
 
   /**
    * Create a page node and verify that a transaction rolls back the failed creation
-- 
1.7.3.2

