View | Details | Raw Unified | Return to bug 19380
Collapse All | Expand All

(-)a/C4/ILSDI/Services.pm (+9 lines)
Lines 239-244 sub GetRecords { Link Here
239
            my $holding_library = Koha::Libraries->find( $item->{holdingbranch} );
239
            my $holding_library = Koha::Libraries->find( $item->{holdingbranch} );
240
            $item->{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
240
            $item->{'homebranchname'}    = $home_library    ? $home_library->branchname    : '';
241
            $item->{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
241
            $item->{'holdingbranchname'} = $holding_library ? $holding_library->branchname : '';
242
243
            my ($transferDate, $transferFrom, $transferTo) = GetTransfers($item->{itemnumber});
244
            if ($transferDate) {
245
                $item->{transfer} = {
246
                    datesent => $transferDate,
247
                    frombranch => $transferFrom,
248
                    tobranch => $transferTo,
249
                };
250
            }
242
        }
251
        }
243
252
244
        # Hashref building...
253
        # Hashref building...
(-)a/t/db_dependent/ILSDI_Services.t (-2 / +57 lines)
Lines 19-29 use Modern::Perl; Link Here
19
19
20
use CGI qw ( -utf8 );
20
use CGI qw ( -utf8 );
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use Test::MockModule;
23
use Test::MockModule;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
26
26
27
use C4::Items qw( ModItemTransfer );
28
use C4::Circulation qw( GetTransfers );
29
27
use Koha::AuthUtils;
30
use Koha::AuthUtils;
28
31
29
BEGIN {
32
BEGIN {
Lines 198-200 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes Link Here
198
    $schema->storage->txn_rollback;
201
    $schema->storage->txn_rollback;
199
};
202
};
200
203
201
- 
204
subtest 'GetRecords' => sub {
205
206
    plan tests => 1;
207
208
    $schema->storage->txn_begin;
209
210
    t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
211
212
    my $branch1 = $builder->build({
213
        source => 'Branch',
214
    });
215
    my $branch2 = $builder->build({
216
        source => 'Branch',
217
    });
218
219
    my $biblio = $builder->build({
220
        source => 'Biblio',
221
    });
222
    my $biblioitem = $builder->build({
223
        source => 'Biblioitem',
224
        value => {
225
            biblionumber => $biblio->{biblionumber},
226
        },
227
    });
228
    my $item = $builder->build({
229
        source => 'Item',
230
        value => {
231
            biblionumber => $biblio->{biblionumber},
232
            biblioitemnumber => $biblioitem->{biblioitemnumber},
233
            homebranch => $branch1->{branchcode},
234
            holdingbranch => $branch1->{branchcode},
235
        },
236
    });
237
238
    ModItemTransfer($item->{itemnumber}, $branch1->{branchcode}, $branch2->{branchcode});
239
240
    my $cgi = new CGI;
241
    $cgi->param(service => 'GetRecords');
242
    $cgi->param(id => $biblio->{biblionumber});
243
244
    my $reply = C4::ILSDI::Services::GetRecords($cgi);
245
246
    my ($datesent, $frombranch, $tobranch) = GetTransfers($item->{itemnumber});
247
    my $expected = {
248
        datesent => $datesent,
249
        frombranch => $frombranch,
250
        tobranch => $tobranch,
251
    };
252
    is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
253
        'GetRecords returns transfer informations');
254
255
    $schema->storage->txn_rollback;
256
};

Return to bug 19380