From 0526ca84264b00e26c2db155641c35f080452c75 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 8 Jun 2023 12:36:52 +0200 Subject: [PATCH] Bug 33953: Adjust tests --- t/db_dependent/Koha/Biblio.t | 8 +++++++- t/db_dependent/Koha/Ratings.t | 9 ++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index d676a79a319..d0945eb0666 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 25; +use Test::More tests => 26; use Test::Exception; use Test::Warn; @@ -1126,6 +1126,12 @@ subtest 'normalized_isbn' => sub { ); }; +subtest 'ratings' => sub { + plan tests => 1; + # See t/db_dependent/Koha/Ratings.t + ok(1); +}; + sub component_record1 { my $marc = MARC::Record->new; $marc->append_fields( diff --git a/t/db_dependent/Koha/Ratings.t b/t/db_dependent/Koha/Ratings.t index faeed427202..664a48133f9 100755 --- a/t/db_dependent/Koha/Ratings.t +++ b/t/db_dependent/Koha/Ratings.t @@ -37,11 +37,11 @@ my $biblionumber = $biblio_1->biblionumber; my $rating_1 = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber}, rating_value => 3 } )->store; my $rating_2 = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $patron_2->{borrowernumber}, rating_value => 4 } )->store; -is( Koha::Ratings->search( { biblionumber => $biblionumber } )->get_avg_rating, 3.5, 'get_avg_rating is 3.5' ); +is( $biblio_1->ratings->get_avg_rating, 3.5, 'get_avg_rating is 3.5' ); $rating_1->rating_value(5)->store; -is( Koha::Ratings->search( { biblionumber => $biblionumber } )->get_avg_rating, 4.5, 'get_avg_rating now up to 4.5' ); +is( $biblio_1->ratings->get_avg_rating, 4.5, 'get_avg_rating now up to 4.5' ); $rating_1->rating_value(42)->store; is( Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber} } )->rating_value, @@ -53,7 +53,6 @@ is( Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $pat Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber} } )->delete; Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $patron_2->{borrowernumber} } )->delete; -is( Koha::Ratings->search( { biblionumber => $biblionumber } )->count, 0, 'Delete should have deleted the ratings' ); - -is( int(Koha::Ratings->search( { biblionumber => $biblionumber } )->get_avg_rating), 0, 'get_avg_rating should return 0 if no rating exist' ); +is( $biblio_1->ratings->count, 0, 'Delete should have deleted the ratings' ); +is( int($biblio_1->ratings->get_avg_rating), 0, 'get_avg_rating should return 0 if no rating exist' ); -- 2.25.1