From d6a04852c8b2394e43a60d9e1e85fb02ffa7ea65 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 31 May 2019 11:41:22 -0500 Subject: [PATCH] Bug 23027: Make Suggestions.t pass even if no biblio in DB There are biblionumbers 1 and 2 hardcoded Test plan: MariaDB [koha_kohadev]> delete from biblioitems; delete from items; delete from biblio; % prove t/db_dependent/Suggestions.t Must return green with this patch applied Signed-off-by: Liz Rea Signed-off-by: Josef Moravec --- t/db_dependent/Suggestions.t | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 16638aac78..96ebc8d234 100644 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -91,13 +91,13 @@ my $member2 = { my $borrowernumber = Koha::Patron->new($member)->store->borrowernumber; my $borrowernumber2 = Koha::Patron->new($member2)->store->borrowernumber; -my $biblionumber1 = 1; +my $biblio_1 = $builder->build_object({ class => 'Koha::Biblios' }); my $my_suggestion = { title => 'my title', author => 'my author', publishercode => 'my publishercode', suggestedby => $borrowernumber, - biblionumber => $biblionumber1, + biblionumber => $biblio_1->biblionumber, branchcode => 'CPL', managedby => '', manageddate => '', @@ -125,7 +125,7 @@ my $my_suggestion_with_budget = { author => 'my author 2', publishercode => 'my publishercode 2', suggestedby => $borrowernumber, - biblionumber => $biblionumber1, + biblionumber => $biblio_1->biblionumber, managedby => '', manageddate => '', accepteddate => dt_from_string, @@ -137,7 +137,7 @@ my $my_suggestion_with_budget2 = { author => 'my author 3', publishercode => 'my publishercode 3', suggestedby => $borrowernumber2, - biblionumber => $biblionumber1, + biblionumber => $biblio_1->biblionumber, managedby => '', manageddate => '', accepteddate => dt_from_string, @@ -273,12 +273,12 @@ is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSugges is( GetSuggestionFromBiblionumber(), undef, 'GetSuggestionFromBiblionumber without the biblio number returns undef' ); is( GetSuggestionFromBiblionumber(2), undef, 'GetSuggestionFromBiblionumber with an invalid biblio number returns undef' ); -is( GetSuggestionFromBiblionumber($biblionumber1), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' ); +is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' ); is( GetSuggestionInfoFromBiblionumber(), undef, 'GetSuggestionInfoFromBiblionumber without the biblio number returns undef' ); is( GetSuggestionInfoFromBiblionumber(2), undef, 'GetSuggestionInfoFromBiblionumber with an invalid biblio number returns undef' ); -$suggestion = GetSuggestionInfoFromBiblionumber($biblionumber1); +$suggestion = GetSuggestionInfoFromBiblionumber($biblio_1->biblionumber); is( $suggestion->{suggestionid}, $my_suggestionid, 'GetSuggestionInfoFromBiblionumber returns the suggestion id correctly' ); is( $suggestion->{title}, $mod_suggestion1->{title}, 'GetSuggestionInfoFromBiblionumber returns the title correctly' ); is( $suggestion->{author}, $mod_suggestion1->{author}, 'GetSuggestionInfoFromBiblionumber returns the author correctly' ); @@ -310,11 +310,11 @@ is( $suggestions->[0]->{categorycodesuggestedby}, $member->{categorycode}, 'GetS is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' ); -my $biblionumber2 = 2; -my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio($my_suggestionid, $biblionumber2); +my $biblio_2 = $builder->build_object({ class => 'Koha::Biblios' }); +my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio($my_suggestionid, $biblio_2->biblionumber); is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' ); $suggestion = GetSuggestion($my_suggestionid); -is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' ); +is( $suggestion->{biblionumber}, $biblio_2->biblionumber, 'ConnectSuggestionAndBiblio updates the biblio number correctly' ); my $search_suggestion = SearchSuggestion(); is( @$search_suggestion, 3, 'SearchSuggestion without arguments returns all suggestions' ); -- 2.11.0