Index: modules/poll/poll.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.test,v
retrieving revision 1.5
diff -u -p -r1.5 poll.test
--- modules/poll/poll.test	5 Aug 2008 18:07:14 -0000	1.5
+++ modules/poll/poll.test	21 Sep 2008 18:26:54 -0000
@@ -79,9 +79,16 @@ class PollCreateTestCase extends PollTes
    * Implementation of getInfo().
    */
   function getInfo() {
-    return array('name' => t('Poll create'), 'description' => 'Adds "more choices", previews and creates a poll.', 'group' => t('Poll'));
+    return array(
+      'name' => t('Poll create'),
+      'description' => t('Adds "more choices", previews and creates a poll.'), 
+      'group' => t('Poll')
+    );
   }
 
+  /**
+   * Implementation of setUp().
+   */
   function setUp() {
     parent::setUp('poll');
   }
@@ -98,9 +105,16 @@ class PollVoteTestCase extends PollTestC
    * Implementation of getInfo().
    */
   function getInfo() {
-    return array('name' => t('Poll vote'), 'description' => 'Vote on a poll', 'group' => t('Poll'));
+    return array(
+      'name' => t('Poll vote'),
+      'description' => t('Vote on a poll'),
+      'group' => t('Poll')
+    );
   }
 
+  /**
+   * Implementation of setUp().
+   */
   function setUp() {
     parent::setUp('poll');
   }
@@ -131,3 +145,73 @@ class PollVoteTestCase extends PollTestC
   }
 }
 
+class PollMostRecentBlockTestCase extends PollTestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Most recent poll block'),
+      'description' => t('Test the most recent poll block.'), 
+      'group' => t('Poll')
+    );
+  }
+
+  /**
+   * Implementation of setUp().
+   */
+  function setUp() {
+    parent::setUp('poll');
+
+    // Create and login user.
+    $admin_user = $this->drupalCreateUser(array('administer blocks', 'create poll content', 'vote on polls', 'access content'));
+    $this->drupalLogin($admin_user);
+  }
+
+  /**
+   * Test the most recent poll block.
+   *  - Test if polls exist/poll block is visible.
+   *  - Create a test poll.
+   *  - Check if the poll is the most recent.
+   */
+  function testMostRecentPollBlock() {
+    // Set the block to region right.
+    $edit = array();
+    $edit['poll_recent[region]'] = 'right';
+    $this->drupalPost('admin/build/block', $edit, t('Save blocks'));
+
+    $this->assertNoRaw('id="block-poll-recent"', t('Poll block is not visible without content.'));
+
+    // Create a sample poll to be used in the test.
+    $title = $this->randomName();
+    $choices = $this->_generateChoices(5);
+    $poll_nid = $this->pollCreate($title, $choices, TRUE);
+
+    $this->assertRaw('id="block-poll-recent"', t('Poll block is visible.'));
+
+    // Change to a user that can vote on the poll just created.
+    $this->drupalLogout();
+    $web_user = $this->drupalCreateUser(array('vote on polls', 'access content'));
+    $this->drupalLogin($web_user);
+
+    // A page where only the right-most poll block is displayed is required.
+    $this->drupalGet('user');
+    $this->assertText($title, t('The correct poll is visible.'));
+
+    // Vote on the Poll.
+    $this->drupalPost('node/'. $poll_nid, array('choice' => 1), t('Vote'));
+
+    // Go to page where poll is only visible in block.
+    $content = $this->drupalGet('user');
+    // Check if the results are shown.
+    $this->assertText(t("Total votes: 1"), t("Block shows results."));
+
+    $secondTitle = $this->randomName();
+    $secondChoices = $this->_generateChoices(6);
+    $this->pollCreate($secondTitle, $secondChoices);
+
+    // A page where only the right-most poll block is displayed is required.
+    $this->drupalGet('user');
+    $this->assertText($secondTitle, t('The most recent poll is shown.'));
+  }
+}
\ No newline at end of file
