- Timestamp:
- 04/15/09 13:35:12 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/t/10Vote_DB.t
r201 r202 8 8 # Structure: 9 9 # { 10 # poll => { var => $val } 10 # poll => { var => $val }, 11 # choices => [ qw() ], 11 12 # voting => [ qw(mail) ], 12 13 # ballot => { 13 14 # # signing from voting list 14 # signing => [ qw() ]# list of items15 # signing => { sbal => [], fsbal => [] } # list of items 15 16 # }, 17 # map => { from => to }, 18 # results => { var => $val }, # wanted results 16 19 # } 17 {} 20 { # an empty poll 21 poll => { label => 'empty poll' }, 22 choices => [ qw(ch1 ch2) ], 23 results => { 24 ballot_count => 0, 25 absolute_majority => 1, 26 } 27 }, 18 28 ]; 19 29 … … 21 31 3 # Fixed test 22 32 + scalar(@$test_polls) * # number of tested polls scenario 23 1; # per poll number of tests33 6; # per poll number of tests 24 34 25 35 use_ok 'Vote', 'Vote'; … … 33 43 foreach my $tpoll (@$test_polls) { 34 44 $count++; 45 diag("Testing vote #$count: " . ($tpoll->{poll}{label} || 'No name')); 35 46 ok(my $pollid = $vote->create_poll('test@', "Vote test $count", "password"), 36 47 "can create a new poll"); 37 48 49 isa_ok(my $poll = $vote->poll($pollid), 'Vote::DB::Poll'); 50 51 foreach (keys %{ $tpoll->{poll} || {}}) { 52 $poll->param($_ => $tpoll->{poll}{$_}); 53 } 54 55 $poll->addupd_voting($_) foreach (@{ $tpoll->{voting} || [] }); 56 57 foreach (@{ $tpoll->{choices} || [] }) { 58 $poll->add_choice($_); 59 } 60 61 ok(eq_set( 62 [ map { $poll->choice($_)->info->{label} } $poll->choices ], 63 $tpoll->{choices} || []), "choices were added"); 64 65 foreach my $name (keys %{ $tpoll->{ballot} || {} }) { 66 $poll->register_ballot( 67 $name, $tpoll->{ballot}{$name}{sbal}, $tpoll->{ballot}{$name}{sbal}, "localtest" 68 ); 69 } 70 71 isa_ok(my $results = $vote->results($pollid), 'Vote::DB::Poll'); 72 73 is($results->ballot_count, $tpoll->{results}{ballot_count} || 0, 74 "can get ballot count"); 75 is($results->absolute_majority, $tpoll->{results}{absolute_majority}, 76 "can get absolute majority"); 77 78 my $res = $results->results_count; 79 38 80 $vote->rollback; 39 81 }
Note: See TracChangeset
for help on using the changeset viewer.