From 6a437dba635d90fd6a568e3fd357dcee64596881 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 3 Sep 2020 09:56:00 +0000 Subject: [PATCH] Bug 26364: Check that return value isn't the value we don't want. Don't check for undef It seems sometimes we get an ISBN returned that matches a book in the sample data. One of the Harry Potter books was matching the ISBN. Our real concern is not that we get nothing, but that we don't get the same value we pass in. We should test for that To test: 1 - prove -v t/db_dependent/XISBN.t 2 - The failures are not consistent, so read the code and ensure we are making sense --- C4/XISBN.pm | 1 - t/db_dependent/XISBN.t | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/C4/XISBN.pm b/C4/XISBN.pm index de9dc100fe..6f7c3bf4bc 100644 --- a/C4/XISBN.pm +++ b/C4/XISBN.pm @@ -107,7 +107,6 @@ sub get_xisbns { $unique_xisbns->{ $response_data->{content} }++; my $xbiblio= _get_biblio_from_xisbn($response_data->{content}); next unless $xbiblio; - next if $xbiblio->{normalized_isbn} && $xbiblio->{normalized_isbn} eq $isbn; push @xisbns, $xbiblio if $xbiblio && $xbiblio->{biblionumber} ne $biblionumber; } if ( wantarray ) { diff --git a/t/db_dependent/XISBN.t b/t/db_dependent/XISBN.t index 4cc939d28a..4579ef0e12 100755 --- a/t/db_dependent/XISBN.t +++ b/t/db_dependent/XISBN.t @@ -76,8 +76,8 @@ eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1,$biblionumber3); }; SKIP: { skip "Problem retrieving ThingISBN", 1 unless $@ eq ''; - is( $results_thingisbn->[0]->{biblionumber}, - undef, + isnt( $results_thingisbn->[0]->{biblionumber}, + $biblionumber3, "Doesn't get biblionumber if the biblionumber matches the one passed to the sub." ); } -- 2.11.0