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	26 Dec 2007 21:58:42 -0000
@@ -13,6 +13,7 @@
   var $_cleanupVariables = array();
   var $_cleanupUsers     = array();
   var $_cleanupRoles     = array();
+  var $_cleanupNodes     = array();
 
 
   function DrupalTestCase($label = NULL) {
@@ -24,6 +25,59 @@
     }
     $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 (!isset($account)) {
+      global $user;
+      $account = $user;
+    }
+
+    // Populate defaults array
+    $defaults = array(
+      'body'      => $this->randomName(32),
+      'title'     => $this->randomName(8),
+      '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
+    $defaults['created'] = $modifying ? $mod_node['created'] : $deafults['changed'];
+    $defaults['date'] = format_date($defaults['created'], 'custom', 'Y-m-d H:i:s O');
+    
+    $node = (object)($settings + $mod_node + $default);
+    
+    node_save($node);
+    $this->_cleanupNodes[] = $node->nid;
+    return $node;
+  }
+
   
   /**
    * @abstract Checks to see if we need to send 
@@ -384,6 +438,10 @@
         $this->assertTrue(TRUE, "$type: $msg");
       }
     }
+
+    foreach ($this->_cleanupNodes as $nid) {
+      node_delete($node);
+    }
     
     parent::tearDown();
   }

