Posted by cwgordon7 on August 16, 2008 at 2:18am
| 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
Patch testing anonymous voting attached. It's perhaps a bit verbose, feel free to cull :) - feedback appreciated.
#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
#4
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
#6
Moving this out of the critical bugs queue - see #607038: Meta issue: fix gaps in code coverage.
#7
Anonymous voting seems to be tested quite extensively now.. closing this old issue :)