Index: journal.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/journal/journal.install,v
retrieving revision 1.7
diff -u -p -r1.7 journal.install
--- journal.install	3 Nov 2008 23:17:50 -0000	1.7
+++ journal.install	12 Jun 2009 05:47:04 -0000
@@ -2,6 +2,11 @@
 // $Id: journal.install,v 1.7 2008/11/03 23:17:50 sun Exp $
 
 /**
+ * @file
+ * journal.install for the journal module
+ */
+
+/**
  * Implementation of hook_schema().
  */
 function journal_schema() {
Index: journal.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/journal/journal.module,v
retrieving revision 1.18
diff -u -p -r1.18 journal.module
--- journal.module	5 Jun 2009 16:30:23 -0000	1.18
+++ journal.module	12 Jun 2009 05:47:06 -0000
@@ -139,6 +139,8 @@ function journal_form_alter(&$form, &$fo
     '#description' => t('If not empty, contents of this field will be logged to the system journal.'),
     '#required' => $entry_required,
     '#wysiwyg' => FALSE,
+    #bug fix for issue 474422
+    '#tree' => FALSE,
   );
   if ($entry_required && user_access('access devel information')) {
     $form['journal']['journal_entry']['#required'] = FALSE;
@@ -239,7 +241,7 @@ function journal_block($op = 'list', $de
   }
   else if ($op == 'view' && user_access('access journal')) {
     $block = array();
-    switch($delta) {
+    switch ($delta) {
       case 'backlog':
         $result = db_query("SELECT j.*, u.name FROM {journal} j INNER JOIN {users} u ON j.uid = u.uid WHERE j.location = '%s' ORDER BY j.timestamp DESC", $_GET['q']);
         if ($output = journal_output($result, 'list')) {
@@ -296,7 +298,7 @@ function journal_view() {
 function journal_output($journal, $format = 'table', $header = array()) {
   switch ($format) {
     case 'text':
-      // Output delimiter in first line, since this may chance.
+      // Output delimiter in first line, since this may change.
       $output = '\t' . "\n";
       
       while ($entry = (is_array($journal) ? array_shift($journal) : db_fetch_object($journal))) {
Index: journal.test
===================================================================
RCS file: journal.test
diff -N journal.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ journal.test	12 Jun 2009 05:47:06 -0000
@@ -0,0 +1,163 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Simpletest integration for theJournal module
+ */
+
+class JournalTestCase extends DrupalWebTestCase {
+  /** this array will store that blocks that we add so they can later be 
+   * remoced in the tearDown() function
+   */
+  var $blocks = array();
+
+  /** Required simpletest methods */
+  /**
+   * Implementation of getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      // 'name' should start with what is being tested (menu item) followed by what
+      // about it is being tested (creation/deletion).
+     'name' => t('Journal module functionality'),
+
+      // 'description' should be one or more complete sentences
+      // explaining the test.
+      'description' => t('Test the journal module functionality.'),
+
+      // 'group' should be a logical grouping of test cases, like a category.
+      // Suggestion: Use the name of the module to be tested.
+      'group' => t('Journal'),
+    );
+  }
+
+  function setUp() {
+    parent::setUp('journal', 'content', 'text');
+
+    $user = $this->drupalCreateUser(array(
+      0 => 'administer blocks',
+      1 => 'access journal',
+      2 => 'administer content types',
+    ));
+    $this->drupalLogin($user);
+  }
+
+  /** TODO: if testJournal479358 succeeded we need to put the block back */
+  function tearDown() {
+    parent::tearDown();
+
+    #foreach ($block as $blocks) {
+    #}
+  }
+
+
+  /** Unit tests */
+
+  /** Functional tests */
+
+  /** 
+   * Tests a basic journal entry
+   */
+  function testJournalAddJournal() {
+    /** Add a new block */
+    $title = $this->randomName(8);
+    $description = $this->randomName(8);
+    $blocks[] = $title;
+    $journal_entry = $this->randomName(8);
+
+    $edit = array(
+      'info' => $description,
+      'title' => $title,
+      'body' => $this->randomName(8),
+      'pages' => '',
+      'journal_entry' => $journal_entry,
+    );
+
+    $this->drupalPost('admin/build/block/add', $edit, 'Save block');
+    $this->assertText($description, t('Verify that the block was added'));
+    $this->drupalGet(url('admin/reports/journal', array("absolute" => TRUE)));
+    $handle = fopen('/tmp/journaltest.html', 'w');
+    fwrite($handle, $this->drupalGetContent());
+    fclose($handle);
+    $this->assertText($journal_entry, t('Verify that the journal entry is listed'));
+  }
+
+  /**
+   * Test of a bug that would not allow journal to add entries with cck enabled
+   * at url: admin/content/node-type/[content-type-name]/display
+   *
+   * Issue: http://drupal.org/node/479358
+   * create a new text type
+   * add it to the story type
+   * do to admin/content/node-type/story/display
+   * submit with a journal and make sure that it exists
+   */
+  function testJournal479358() {
+    /** Add the new field: admin/content/node-type/story/fields */
+
+    /** note it is required that this is all lower case */
+    $field_name = strtolower($this->randomName(8));
+    $edit = array(
+      '_add_new_field[label]' => $this->randomName(8),
+      '_add_new_field[field_name]' => $field_name,
+      '_add_new_field[type]' => 'text',
+      '_add_new_field[widget_type]' => 'text_textfield',
+    );
+    $this->drupalPost('admin/content/node-type/story/fields', $edit, 'Save');
+
+    /** Test the display: admin/content/node-type/story/display */
+    $journal_entry = $this->randomName(8);
+    $edit = array(
+      'journal_entry' => $journal_entry,
+    );
+    $this->drupalPost('admin/content/node-type/story/display', $edit, 'Save');
+
+    $handle = fopen('/tmp/simpletest.html', 'w');
+    fwrite($handle, $this->drupalGetContent());
+    fclose($handle);
+
+    $this->drupalGet(url('admin/reports/journal', array("absolute" => TRUE)));
+    $this->assertText($journal_entry, t('Verify that the journal entry is listed'));
+  }
+
+  /**
+   * Test of a bug that would not allow journal to add entries under certain circumstances 
+   *
+   * Issue: http://drupal.org/node/474422
+   * Log into the site
+   * enable a module from admin/build/blocks, adding a journal entry
+   * journal entry should be in journal log (admin/reports/journal)
+   */
+  function testJournal474422() {
+
+    /** Add a new block */
+    $title = $this->randomName(8);
+    $blocks[] = $title;
+    $journal_entry = $this->randomName(8);
+
+    $edit = array(
+      'info' => $this->randomName(8),
+      'title' => $title,
+      'body' => $this->randomName(8),
+      'pages' => '',
+      'journal_entry' => $journal_entry,
+    );
+
+    $this->drupalPost('admin/build/block/add', $edit, 'Save block');
+
+    /** TODO: e need to get the form values for the Journal entries form */
+    /** Position the new block addinga journal entry */
+    $journal_entry = $this->randomName(8);
+    $edit = array(
+      'journal_backlog[region]' => 'right',
+      'journal_entry' => $journal_entry,
+    );
+
+    $this->drupalPost('admin/build/block', $edit, 'Save blocks');
+
+    $this->drupalGet(url('admin/reports/journal', array("absolute" => TRUE)));
+    $this->assertText($journal_entry, t('Verify that the journal entry is listed'));
+  }
+
+}
