From 8cbead9734f572d4b805d515f86df4b46f570275 Mon Sep 17 00:00:00 2001 From: Ian Walls Date: Wed, 21 Mar 2012 21:33:53 -0400 Subject: [PATCH] Enh 5668 Followup: only run borrower-specific unit tests if borrowers exist If the borrowers 102 and 103 don't exist, skip the tests that call for them. This leaves just 2 running tests on most DBs, but this will help quiet the automated test suites, and will still run if the right data is installed. --- t/db_dependent/Ratings.t | 44 +++++++++++++++++++++++++------------------- 1 files changed, 25 insertions(+), 19 deletions(-) diff --git a/t/db_dependent/Ratings.t b/t/db_dependent/Ratings.t index 0c2aee5..23bde86 100755 --- a/t/db_dependent/Ratings.t +++ b/t/db_dependent/Ratings.t @@ -3,6 +3,7 @@ use strict; use warnings; use Test::More tests => 12; +use C4::Members; BEGIN { @@ -13,27 +14,32 @@ BEGIN { DelRating( 1, 901 ); DelRating( 1, 902 ); - my $rating1 = AddRating( 1, 102, 3 ); - my $rating2 = AddRating( 1, 103, 4 ); - my $rating3 = ModRating( 1, 102, 5 ); - my $rating4 = GetRating( 1, 103 ); my $rating5 = GetRating( 1, undef ); - my $rating6 = DelRating( 1, 102 ); - my $rating7 = DelRating( 1, 103 ); - - ok( defined $rating1, 'add a rating' ); - ok( defined $rating2, 'add another rating' ); - ok( defined $rating3, 'update a rating' ); - ok( defined $rating4, 'get a rating, with borrowernumber' ); ok( defined $rating5, 'get a rating, without borrowernumber' ); - ok( $rating3->{'rating_avg'} == '4', "get a bib's average(float) rating" ); - 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" ); - ok( defined $rating6, 'delete a rating' ); - ok( defined $rating7, 'delete another rating' ); + + my $borrower102 = GetMember( borrowernumber => 102); + my $borrower103 = GetMember( borrowernumber => 103); + SKIP: { + skip 'Missing test borrowers, skipping specific tests', 10 unless ( defined $borrower102 && defined $borrower103 ); + my $rating1 = AddRating( 1, 102, 3 ); + my $rating2 = AddRating( 1, 103, 4 ); + my $rating3 = ModRating( 1, 102, 5 ); + my $rating4 = GetRating( 1, 103 ); + my $rating6 = DelRating( 1, 102 ); + my $rating7 = DelRating( 1, 103 ); + + ok( defined $rating1, 'add a rating' ); + ok( defined $rating2, 'add another rating' ); + ok( defined $rating3, 'update a rating' ); + ok( defined $rating4, 'get a rating, with borrowernumber' ); + ok( defined $rating6, 'delete a rating' ); + ok( defined $rating7, 'delete another rating' ); + + ok( $rating3->{'rating_avg'} == '4', "get a bib's average(float) rating" ); + 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" ); + } } -- 1.7.0.4