For a biblio with multiple ISBNS we sometimes get our own record back when
check XISBN, we should test for this
To test:
1 - Edit a record in the catalogue, add two isbns:
0521240670
0521284198
2 - Enable ThingISBN and FRBRizeEditions and OPACFRBRizeEditions
3 - View the record in staff and OPAC
4 - You should see editions tab pointing to the same record
5 - Apply patch
6 - Reload the record details, you should no longer see editions tab
7 - Add the second ISBN to another record
8 - Reload details for original record, you shoudl see editions linking to the record with second ISBN
9 - prove -v t/db_dependent/XISBN.t
NOTE: Current tests don't work under elasticsearch, but the code does, tests should be rewritten on another bug
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com>
Signed-off-by: Arthur Bousquet <arthur.bousquet@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
return $biblio;
}
-=head1 get_xisbns($isbn);
+=head1 get_xisbns($isbn, $biblionumber);
=head2 $isbn is an ISBN string
=cut
sub get_xisbns {
- my ( $isbn ) = @_;
+ my ( $isbn, $biblionumber ) = @_;
my ($response,$thing_response,$syndetics_response,$errors);
# THINGISBN
if ( C4::Context->preference('ThingISBN') ) {
next if $unique_xisbns->{ $response_data->{content} };
$unique_xisbns->{ $response_data->{content} }++;
my $xbiblio= _get_biblio_from_xisbn($response_data->{content});
- push @xisbns, $xbiblio if $xbiblio;
+ push @xisbns, $xbiblio if $xbiblio && $xbiblio->{biblionumber} ne $biblionumber;
}
if ( wantarray ) {
return (\@xisbns, $errors);
if (C4::Context->preference("FRBRizeEditions")==1) {
eval {
$template->param(
- XISBNS => scalar get_xisbns($isbn)
+ XISBNS => scalar get_xisbns($isbn, $biblionumber)
);
};
if ($@) { warn "XISBN Failed $@"; }
if (C4::Context->preference("OPACFRBRizeEditions")==1) {
eval {
$template->param(
- XISBNS => scalar get_xisbns($isbn)
+ XISBNS => scalar get_xisbns($isbn, $biblionumber)
);
};
if ($@) { warn "XISBN Failed $@"; }
use Modern::Perl;
-use Test::More tests => 3;
+use Test::More tests => 5;
use MARC::Record;
use C4::Biblio;
use C4::XISBN;
"Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
}
+eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1,$biblionumber1); };
+SKIP: {
+ skip "Problem retrieving ThingISBN", 1
+ unless $@ eq '';
+ is( $results_thingisbn->[0]->{biblionumber},
+ $biblionumber3,
+ "Gets correct biblionumber from a different book with a similar isbn using ThingISBN." );
+}
+
+eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1,$biblionumber3); };
+SKIP: {
+ skip "Problem retrieving ThingISBN", 1
+ unless $@ eq '';
+ is( $results_thingisbn->[0]->{biblionumber},
+ undef,
+ "Doesn't get biblionumber if the biblionumber matches the one passed to the sub." );
+}
+
# Util subs
# Add new biblio with isbn and return biblionumber