? .DS_Store
? simpletest
? tests/.DS_Store
Index: drupal_test_case.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_test_case.php,v
retrieving revision 1.40
diff -u -r1.40 drupal_test_case.php
--- drupal_test_case.php	7 Jan 2008 13:22:38 -0000	1.40
+++ drupal_test_case.php	8 Jan 2008 09:54:11 -0000
@@ -13,6 +13,7 @@
   var $_cleanupVariables = array();
   var $_cleanupUsers     = array();
   var $_cleanupRoles     = array();
+  var $_cleanupNodes     = array();
 
 
   function DrupalTestCase($label = NULL) {
@@ -24,6 +25,47 @@
     }
     $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!'
+   */
+  function drupalCreateNode($settings = array()) {
+ 
+    // Populate defaults array
+    $defaults = array(
+      'body'      => $this->randomName(32),
+      'title'     => $this->randomName(8),
+      'comment'   => 2,
+      'changed'   => time(),
+      'format'    => 1,
+      'moderate'  => 0,
+      '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['date'] = format_date($defaults['created'], 'custom', 'Y-m-d H:i:s O');
+    
+    if (empty($settings['uid'])) {
+      global $user;
+      $defaults['uid'] = $user->uid;
+    }
+    $node = ($settings + $defaults);
+    $node = (object)$node;
+ 
+    node_save($node);
+    $this->_cleanupNodes[] = $node->nid;
+    return $node;
+  }
+
 
   /**
    * @abstract Checks to see if we need to send
@@ -366,6 +408,12 @@
       }
     }
     $this->_cleanupVariables = array();
+    
+    
+    foreach ($this->_cleanupNodes as $nid) {
+      node_delete($nid);
+    }
+
 
     while (sizeof($this->_cleanupRoles) > 0) {
       $rid = array_pop($this->_cleanupRoles);
Index: tests/content_actions.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/content_actions.test,v
retrieving revision 1.1
diff -u -r1.1 content_actions.test
--- tests/content_actions.test	27 Dec 2007 07:37:50 -0000	1.1
+++ tests/content_actions.test	8 Jan 2008 09:54:11 -0000
@@ -8,13 +8,25 @@
    * Implementation of get_info() for information
    */
   function get_info() {
-    return array('name' => t('Actions content'), 'desc' => t('Perform various tests with content actions.') , 'group' => 'Actions');
+    return array(
+      'name' => t('Actions content'),
+      'desc' => t('Perform various tests with content actions.') ,
+      'group' => 'Actions',
+    );
   }
 
   /**
    * Setup function
    */
-  function setup() {
+  function setUp() {
+    parent::setUp();
+  }
+  
+  /**
+   * Teardown function
+   */
+  function tearDown(){
+    parent::tearDown();
   }
 
   /**
@@ -30,15 +42,12 @@
     $hash = md5('node_publish_action');
 
     $not_clean = db_result(db_query("SELECT COUNT(*) FROM {trigger_assignments} WHERE aid IN ('". implode("','", $content_actions) ."')"));
-    
+    $this->assertFalse($not_clean, t('Actions were already assigned to the trigger. Unassign all content triggers before attempting to run again.'));
+
     if ($not_clean) {
-      $this->assertFalse($not_clean, t('Actions were already assigned to the trigger. Unassign all content triggers before attempting to run again.'));
       return;
     }
-    else {
-      $this->assertFalse($not_clean, t('Actions were already not assigned to the trigger.'));
-    }
-
+    
     // Test 1: Assign an action to a trigger, then pull the trigger, and make sure the actions fire. (Wow, those metaphors work out nicely).
 
     $test_user = $this->drupalCreateUserRolePerm(array('administer actions', 'create page content'));
@@ -49,21 +58,7 @@
     $this->drupalPostRequest('admin/build/trigger/node', $edit, 'Assign');
 
     // Create an unpublished node.
-    $node->body      = $this->randomName(32);
-    $node->title     = $this->randomName(8);
-    $node->teaser    = $node->body;
-    $node->comment   = 2;
-    $node->format    = 1;
-    $node->name      = $test_user->name;
-    $node->uid       = $test_user->uid;
-    $node->promote   = 0;
-    $node->revision  = 0;
-    $node->status    = 0;
-    $node->sticky    = 0;
-    $node->type      = 'page';
-    $node->revisions = NULL;
-    $node->taxonomy  = NULL;
-    node_save($node);
+    $node = $this->drupalCreateNode(array('status' => 0));
     // Node should be published automatically.
     $loaded_node = node_load($node->nid);
     $this->assertTrue($loaded_node->status == 1, t('Check to make sure the node is automatically published'));
Index: tests/node_revisions.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/node_revisions.test,v
retrieving revision 1.2
diff -u -r1.2 node_revisions.test
--- tests/node_revisions.test	5 Jan 2008 10:21:57 -0000	1.2
+++ tests/node_revisions.test	8 Jan 2008 09:54:12 -0000
@@ -21,42 +21,27 @@
     global $user;
 
     $returnarray = array();
-    $node = new stdClass();
     $numtimes = 3; // First, middle, last.
     for ($i = 0; $i < $numtimes; $i++) {
-      $node->body      = $this->randomName(32 + $i);
-      $node->title     = $this->randomName(8 + $i);
-      $node->teaser    = $node->body;
-      $node->comment   = '2';
-      $node->created   = time();
-      $node->date      = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
-      $node->format    = '1';
-      $node->moderate  = 0;
-      $node->name      = $user->name;
-      $node->uid       = $user->uid;
-      $node->promote   = 0;
-      $node->revision  = 1;
-      $node->log     = '';
-      if ($i == 1 && $log) {
-        $logmessage    = $this->randomName(32);
-        $node->log     = $logmessage;
+      $settings = array('revision' => 1);
+      if ($log && $i == 1) {
+        $logmessage = $this->randomName(32);
+        $settings['log'] = $logmessage;
         $returnarray['log'] = $logmessage;
       }
-      $node->status    = '1';
-      $node->sticky    = 0;
-      $node->type      = 'page';
-      $node->revisions = NULL;
-      $node->changed   = $node->created;
-      $node->taxonomy  = NULL;
-      node_save($node);
-      // Avoid confusion on the revisions overview page which is sorted by r.timestamp.
-      sleep(1);
       if ($i == 1) {
-        $text          = $node->body;
-        $vid           = $node->vid;
-        $returnarray['vid'] = $vid;
-        $returnarray['text'] = $text;
+        $settings['body'] = $this->randomName(32);
+        $returnarray['text'] = $settings['body'];
+        $settings['vid'] = $node->vid;
+        $returnarray['vid'] = $node->vid;
+      }
+      $mod_node = NULL;
+      if ($i != 0) {
+        $mod_node = $node;
       }
+      $node = $this->drupalCreateNode($settings, NULL, $mod_node);
+      // Avoid confusion on the revisions overview page which is sorted by r.timestamp.
+      sleep(1);
     }
     $returnarray['node'] = $node;
     return $returnarray;
Index: tests/page_view.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/tests/page_view.test,v
retrieving revision 1.12
diff -u -r1.12 page_view.test
--- tests/page_view.test	5 Jan 2008 10:21:57 -0000	1.12
+++ tests/page_view.test	8 Jan 2008 09:54:12 -0000
@@ -18,26 +18,7 @@
   function testPageView() {
     /* Prepare a node to view */
     global $user;
-    $node = new stdClass();
-    $node->body      = $this->randomName(32);
-    $node->title     = $this->randomName(8);
-    $node->teaser    = $node->body;
-    $node->comment   = '2';
-    $node->created   = time();
-    $node->date      = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
-    $node->format    = '1';
-    $node->moderate  = 0;
-    $node->name      = $user->name;
-    $node->uid       = $user->uid;
-    $node->promote   = 0;
-    $node->revision  = 0;
-    $node->status    = '1';
-    $node->sticky    = 0;
-    $node->type      = 'page';
-    $node->revisions = NULL;
-    $node->changed   = $node->created;
-    $node->taxonomy  = NULL;
-    node_save($node);
+    $node = $this->drupalCreateNode();
     $this->assertNotNull(node_load($node->nid), 'Node created');
 
     /* Tries to edit with anonymous user */
