Bug 9032: (follow-up) add support for bootstrap theme
[koha.git] / t / db_dependent / Ratings.t
blob23bde868289d97c9b3adbd76fd94534c8f82e73f
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
5 use Test::More tests => 12;
6 use C4::Members;
8 BEGIN {
10 use FindBin;
11 use C4::Ratings;
12 use_ok('C4::Ratings');
14 DelRating( 1, 901 );
15 DelRating( 1, 902 );
17 my $rating5 = GetRating( 1, undef );
18 ok( defined $rating5, 'get a rating, without borrowernumber' );
20 my $borrower102 = GetMember( borrowernumber => 102);
21 my $borrower103 = GetMember( borrowernumber => 103);
22 SKIP: {
23 skip 'Missing test borrowers, skipping specific tests', 10 unless ( defined $borrower102 && defined $borrower103 );
24 my $rating1 = AddRating( 1, 102, 3 );
25 my $rating2 = AddRating( 1, 103, 4 );
26 my $rating3 = ModRating( 1, 102, 5 );
27 my $rating4 = GetRating( 1, 103 );
28 my $rating6 = DelRating( 1, 102 );
29 my $rating7 = DelRating( 1, 103 );
31 ok( defined $rating1, 'add a rating' );
32 ok( defined $rating2, 'add another rating' );
33 ok( defined $rating3, 'update a rating' );
34 ok( defined $rating4, 'get a rating, with borrowernumber' );
35 ok( defined $rating6, 'delete a rating' );
36 ok( defined $rating7, 'delete another rating' );
38 ok( $rating3->{'rating_avg'} == '4', "get a bib's average(float) rating" );
39 ok( $rating3->{'rating_avg_int'} == 4.5, "get a bib's average(int) rating" );
40 ok( $rating3->{'rating_total'} == 2, "get a bib's total number of ratings" );
41 ok( $rating3->{'rating_value'} == 5, "verify user's bib rating" );
48 mason@xen1:~/g/head$ perl t/db_dependent/Ratings.t
49 1..12
50 ok 1 - use C4::Ratings;
51 ok 2 - add a rating
52 ok 3 - add another rating
53 ok 4 - update a rating
54 ok 5 - get a rating, with borrowernumber
55 ok 6 - get a rating, without borrowernumber
56 ok 7 - get a bib's average(float) rating
57 ok 8 - get a bib's average(int) rating
58 ok 9 - get a bib's total number of ratings
59 ok 10 - verify user's bib rating
60 ok 11 - delete a rating
61 ok 12 - delete another rating
63 =cut