Index: drupal_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_test_case.php,v
retrieving revision 1.34
diff -u -r1.34 drupal_test_case.php
--- drupal_test_case.php	23 Sep 2007 08:35:23 -0000	1.34
+++ drupal_test_case.php	25 Dec 2007 18:21:31 -0000
@@ -13,6 +13,7 @@
   var $_cleanupVariables = array();
   var $_cleanupUsers     = array();
   var $_cleanupRoles     = array();
+  var $_cleanupNodes     = array();
 
 
   function DrupalTestCase($label = NULL) {
@@ -24,6 +25,64 @@
     }
     $this->WebTestCase($label);
   }
+
+  /**
+   * Creates a node based on default settings.
+   *
+   * @param settings An array of settings to change from the defaults, in the form of 'body' => 'Hello, world!'
+   * @param user A user to use as the author for the node.
+   * @param node A node object if applicable to work with.
+   */
+  function drupalCreateNode($settings = array(), $account = NULL, $mod_node = NULL) {
+    $modifying = FALSE;
+    if (is_object($mod_node)) {
+      $modifying = TRUE;
+      $mod_node = (array) $mod_node;
+    }
+    else {
+      $mod_node = array();
+    }
+    if ($account === NULL) {
+      global $user;
+      $account = $user;
+    }
+
+    // Populate defaults array
+    $defaults = array(
+      'body'      => $this->randomName(32 + $i),
+      'title'     => $this->randomName(8 + $i),
+      'comment'   => '2',
+      'changed'   => time(),
+      'format'    => '1',
+      'moderate'  => 0,
+      'name'      => $account->name,
+      'uid'       => $account->uid,
+      'promote'   => 0,
+      'revision'  => 1,
+      'log'       => '',
+      'status'    => '1',
+      'sticky'    => 0,
+      'type'      => 'page',
+      'revisions' => NULL,
+      'taxonomy'  => NULL,
+    );
+    $defaults['teaser'] = $defaults['body'];
+    // If we already have a node, we use the original node's created time, and this
+    if ($modifying) {
+      $defaults['created'] = $mod_node['created'];
+    }
+    else {
+      $defaults['created'] = $defaults['changed'];
+    }
+    $defaults['date'] = format_date($defaults['created'], 'custom', 'Y-m-d H:i:s O');
+    
+    $node = (object) $mod_node + $settings + $default;
+    
+    node_save($node);
+    $this->_cleanupNodes[] = $node->nid;
+    return $node;
+  }
+
   
   /**
    * @abstract Checks to see if we need to send 
@@ -384,6 +443,10 @@
         $this->assertTrue(TRUE, "$type: $msg");
       }
     }
+
+    foreach ($this->_cleanupNodes as $nid) {
+      node_delete($node);
+    }
     
     parent::tearDown();
   }

