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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

frega’s picture

Status: Active » Needs review
FileSize
5.21 KB

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

sasconsul’s picture

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

sasconsul’s picture

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

jhedstrom’s picture

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:

+    // 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

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

Doxygen comments probably shouldn't be self-referencing:

  /**
   * Test anonymous user poll vote 
   * @see http://drupal.org/node/295994
   */

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

Dave Reid’s picture

Component: tests » poll.module
Issue tags: +anonymous users
catch’s picture

Category: bug » task
Priority: Critical » Normal

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

amateescu’s picture

Status: Needs work » Closed (fixed)

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