Browse Source

Bug 13998: (RM followup) tests expect data on the database

This patch makes t/db_dependent/Ratings.t create its own biblio
instead of using a hardcoded '1' fr the biblionubmer.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
3.20.x
Tomás Cohen Arazi 9 years ago
parent
commit
1c88c819a4
  1. 43
      t/db_dependent/Ratings.t

43
t/db_dependent/Ratings.t

@ -1,9 +1,26 @@
#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 14;
use C4::Members;
use C4::Biblio qw/AddBiblio/;
use C4::Members;
use C4::Context;
use C4::Category;
@ -13,6 +30,8 @@ my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
my ($biblionumber) = AddBiblio( MARC::Record->new, '' );
my @categories = C4::Category->all;
my $categorycode = $categories[0]->categorycode;
my $branchcode = 'CPL';
@ -42,11 +61,11 @@ my %jane_doe = (
my $borrowernumber1 = AddMember(%john_doe);
my $borrowernumber2 = AddMember(%jane_doe);
my $rating1 = AddRating( 1, $borrowernumber1, 3 );
my $rating2 = AddRating( 1, $borrowernumber2, 4 );
my $rating3 = ModRating( 1, $borrowernumber1, 5 );
my $rating4 = GetRating( 1, $borrowernumber2 );
my $rating5 = GetRating(1);
my $rating1 = AddRating( $biblionumber, $borrowernumber1, 3 );
my $rating2 = AddRating( $biblionumber, $borrowernumber2, 4 );
my $rating3 = ModRating( $biblionumber, $borrowernumber1, 5 );
my $rating4 = GetRating( $biblionumber, $borrowernumber2 );
my $rating5 = GetRating( $biblionumber );
ok( defined $rating1, 'add a rating' );
ok( defined $rating2, 'add another rating' );
@ -58,8 +77,8 @@ ok( $rating3->{'rating_avg_int'} == 4.5, "get a bib's average(int) rating" );
ok( $rating3->{'rating_total'} == 2, "get a bib's total number of ratings" );
ok( $rating3->{'rating_value'} == 5, "verify user's bib rating" );
my $rating_1 = GetRating(1);
my $rating_1_1 = GetRating( 1, $borrowernumber1 );
my $rating_1 = GetRating( $biblionumber );
my $rating_1_1 = GetRating( $biblionumber, $borrowernumber1 );
is_deeply(
$rating_1,
{
@ -81,11 +100,13 @@ is_deeply(
'GetRating should return total, avg_int, avg and value if biblionumber is given'
);
my $rating6 = DelRating( 1, $borrowernumber1 );
my $rating7 = DelRating( 1, $borrowernumber2 );
my $rating6 = DelRating( $biblionumber, $borrowernumber1 );
my $rating7 = DelRating( $biblionumber, $borrowernumber2 );
ok( defined $rating6, 'delete a rating' );
ok( defined $rating7, 'delete another rating' );
is( GetRating( 1, $borrowernumber1 ),
is( GetRating( $biblionumber, $borrowernumber1 ),
undef, 'GetRating should return undef if no rating exist' );
1;
Loading…
Cancel
Save