TestingParty08: Anonymous voting on polls

cwgordon7 - August 16, 2008 - 02:18
Project:Drupal
Version:7.x-dev
Component:poll.module
Category:task
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:anonymous users
Description

We need to test anonymous users voting on polls.

Suggested assertions:
- Votes by anonymous users are recorded if they are allowed.
- Anonymous users may not vote more than once.

#1

frega - September 9, 2008 - 18:22
Status:active» needs review

Patch testing anonymous voting attached. It's perhaps a bit verbose, feel free to cull :) - feedback appreciated.

AttachmentSizeStatusTest resultOperations
anonymous_user_poll_test.patch5.21 KBIgnoredNoneNone

#2

sasconsul - October 12, 2008 - 02:51

All 153 passes ran in my install running in XAMPP with PHP 5.2.6 .

#3

sasconsul - October 14, 2008 - 06:47

Folks,

I looked into adding some tests to poll and came up with a way to complete one of the @todo tests for the anonymous poll.

I have also made a new function to assert the vote count of the first poll item.

I hope this helps,
Stuart

AttachmentSizeStatusTest resultOperations
anonymous_user_poll_test_v2.patch5.62 KBIgnoredNoneNone

#4

jhedstrom - October 31, 2008 - 17:12
Status:needs review» needs work

Code formatting needs some work (text and variables concatenated should have spaces between the ' and the ".", associative array declarations need spaces on either side of the "=>"). Comments should be capitalized-sentences ending with punctuation.

In this section:

<?php
+    // from now on as anonymous
+    $this->drupalGet('node/'.$poll_nid);
+   
$this->assertResponse(200, t('We should be able to access a poll'));
+   
$this->drupalGet('node/'.$poll_nid);
?>

You don't need to call drupalGet() again after asserting the response.

Also, if this patch goes in after #300993: User roles and permissions API then the section for granting the permission can be reduced to

<?php
  $this
->drupalAnonymousUserPermissions(array('cancel own vote', 'vote on polls'));
?>

Doxygen comments probably shouldn't be self-referencing:

<?php
 
/**
   * Test anonymous user poll vote
   * @see <a href="http://drupal.org/node/295994
" title="http://drupal.org/node/295994
" rel="nofollow">http://drupal.org/node/295994
</a>   */
?>

Instead, a simple explanation of the types of tests contained in the function would suffice.

#5

Dave Reid - February 13, 2009 - 20:19
Component:tests» poll.module

#6

catch - October 17, 2009 - 07:49
Category:bug report» task
Priority:critical» normal

Moving this out of the critical bugs queue - see #607038: Meta issue: fix gaps in code coverage.

 
 

Drupal is a registered trademark of Dries Buytaert.