source: trunk/t/11Epoll_DB_crypted.t @ 269

Last change on this file since 269 was 242, checked in by nanardon, 15 years ago
  • rename Vote module to Epoll (#16)
  • Property svn:keywords set to Id Rev
File size: 1.0 KB
Line 
1use strict;
2use warnings;
3use Test::More tests => 13;
4
5# $Id$
6
7use_ok 'Epoll', 'Epoll';
8use_ok 'Epoll::DB';
9$ENV{EPOLL_NO_COMMIT} = 1;
10isa_ok(my $vote = Epoll::DB->new(Epoll->config->{db}), 'Epoll::DB');
11
12ok(my $pollid = $vote->create_poll('test@', "Vote test", "password"),
13    "can create a new poll");
14
15isa_ok(my $poll = $vote->poll($pollid), 'Epoll::DB::Poll');
16
17ok($poll->gen_poll_keys('keypass'), 'can generate poll keys');
18
19$poll->addupd_voting($_) foreach (qw(a b c));
20
21$poll->register_ballot('a', ['ch', 'ch2'], 'localhost');
22$poll->register_ballot('b', ['ch'], 'localhost');
23$poll->register_ballot('c', [], 'localhost');
24
25isa_ok(my $results = $vote->results($pollid), 'Epoll::DB::Poll');
26
27ok($results->decrypted_ballots('keypass'), "Can decrypt ballot");
28
29is($results->ballot_count_crypt, 3, "ballot count is 3");
30is($results->ballot_count_clear, 3, "ballot count is 3");
31
32ok(my $res = $results->results, "can get results");
33is($res->[0]->{value}, 'ch', "winner is ch");
34is($res->[0]->{count}, 2, "winner has two voices");
35
36$vote->db->rollback; # really rollback
Note: See TracBrowser for help on using the repository browser.