Bug 19380: Add transfer informations in ILS-DI GetRecords response

Test plan:
1. Put an item into a 'transfer' state
  a. Place a hold on an item in branch A for a patron of branch B
  b. Check in this item in branch A and confirm transfer
2. Go to http://opac/cgi-bin/koha/ilsdi.pl?service=GetRecords&id=XXX
   where XXX is the biblionumber of the biblio the item belongs to.
3. Verify you have a new <transfer> element inside //record/items/item
   that contains <datesent>, <frombranch> and <tobranch>
4. Check in the same item in branch B, so that the item is not flagged
   as being transferred
5. Repeat 2
6. Verify that the <transfer> element is not there.
7. prove t/db_dependent/ILSDI_Services.t

Followed test plan, patch worked as described. Also ran QA test tools
and modified files passed

Signed-off-by: Alex Buckley <alexbuckley@catalyst.net.nz>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Julian Maurice 2017-09-27 15:32:53 +02:00 committed by Nick Clemens
parent 94206510d7
commit 1611c13e85
2 changed files with 68 additions and 3 deletions

View file

@ -243,6 +243,15 @@ sub GetRecords {
my $holding_library = Koha::Libraries->find( $item->{holdingbranch} );
$item->{'homebranchname'} = $home_library ? $home_library->branchname : '';
$item->{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
my ($transferDate, $transferFrom, $transferTo) = GetTransfers($item->{itemnumber});
if ($transferDate) {
$item->{transfer} = {
datesent => $transferDate,
frombranch => $transferFrom,
tobranch => $transferTo,
};
}
}
# Hashref building...

View file

@ -19,11 +19,14 @@ use Modern::Perl;
use CGI qw ( -utf8 );
use Test::More tests => 6;
use Test::More tests => 7;
use Test::MockModule;
use t::lib::Mocks;
use t::lib::TestBuilder;
use C4::Items qw( ModItemTransfer );
use C4::Circulation qw( GetTransfers );
use Koha::AuthUtils;
BEGIN {
@ -242,7 +245,6 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
$schema->storage->txn_rollback;
};
subtest 'LookupPatron test' => sub {
plan tests => 9;
@ -540,4 +542,58 @@ subtest 'Holds test for branch transfer limits' => sub {
is( $reply->{code}, undef, "Record hold, Item con be transferred" );
$schema->storage->txn_rollback;
}
};
subtest 'GetRecords' => sub {
plan tests => 1;
$schema->storage->txn_begin;
t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
my $branch1 = $builder->build({
source => 'Branch',
});
my $branch2 = $builder->build({
source => 'Branch',
});
my $biblio = $builder->build({
source => 'Biblio',
});
my $biblioitem = $builder->build({
source => 'Biblioitem',
value => {
biblionumber => $biblio->{biblionumber},
},
});
my $item = $builder->build({
source => 'Item',
value => {
biblionumber => $biblio->{biblionumber},
biblioitemnumber => $biblioitem->{biblioitemnumber},
homebranch => $branch1->{branchcode},
holdingbranch => $branch1->{branchcode},
},
});
ModItemTransfer($item->{itemnumber}, $branch1->{branchcode}, $branch2->{branchcode});
my $cgi = new CGI;
$cgi->param(service => 'GetRecords');
$cgi->param(id => $biblio->{biblionumber});
my $reply = C4::ILSDI::Services::GetRecords($cgi);
my ($datesent, $frombranch, $tobranch) = GetTransfers($item->{itemnumber});
my $expected = {
datesent => $datesent,
frombranch => $frombranch,
tobranch => $tobranch,
};
is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
'GetRecords returns transfer informations');
$schema->storage->txn_rollback;
};