Download & Extend

TestingParty08: Anonymous voting on polls

Project:Drupal core
Version:7.x-dev
Component:poll.module
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:anonymous users

Issue Summary

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.

Comments

#1

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 KBIgnored: Check issue status.NoneNone

#2

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

#3

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 KBIgnored: Check issue status.NoneNone

#4

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

Component:tests» poll.module

#6

Category:bug report» task
Priority:critical» normal

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

#7

Status:needs work» closed (fixed)

Anonymous voting seems to be tested quite extensively now.. closing this old issue :)