3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 10;
25 use t::lib::TestBuilder;
28 use C4::Items qw( ModItemTransfer );
29 use C4::Circulation qw( AddIssue );
32 use Koha::DateUtils qw( dt_from_string );
35 use_ok('C4::ILSDI::Services', qw( AuthenticatePatron GetPatronInfo LookupPatron HoldTitle HoldItem GetRecords RenewLoan ));
38 my $schema = Koha::Database->schema;
39 my $dbh = C4::Context->dbh;
40 my $builder = t::lib::TestBuilder->new;
42 subtest 'AuthenticatePatron test' => sub {
46 $schema->storage->txn_begin;
48 my $plain_password = 'tomasito';
57 my $borrower = $builder->build({
61 password => Koha::AuthUtils::hash_password( $plain_password ),
62 lastseen => "2001-01-01 12:34:56"
67 $query->param( 'username', $borrower->{userid});
68 $query->param( 'password', $plain_password);
70 t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' );
71 my $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
72 is( $reply->{id}, $borrower->{borrowernumber}, "userid and password - Patron authenticated" );
73 is( $reply->{code}, undef, "Error code undef");
74 my $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} });
75 is( $seen_patron->lastseen(), '2001-01-01 12:34:56','Last seen not updated if not tracking patrons');
77 $query->param('password','ilsdi-passworD');
78 $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
79 is( $reply->{code}, 'PatronNotFound', "userid and wrong password - PatronNotFound" );
80 is( $reply->{id}, undef, "id undef");
82 $query->param( 'password', $plain_password );
83 $query->param( 'username', 'wrong-ilsdi-useriD' );
84 $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
85 is( $reply->{code}, 'PatronNotFound', "non-existing userid - PatronNotFound" );
86 is( $reply->{id}, undef, "id undef");
88 t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' );
89 $query->param( 'username', uc( $borrower->{userid} ));
90 $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
91 my $now = dt_from_string;
92 is( $reply->{id}, $borrower->{borrowernumber}, "userid is not case sensitive - Patron authenticated" );
93 is( $reply->{code}, undef, "Error code undef");
94 $seen_patron = Koha::Patrons->find({ borrowernumber => $reply->{id} });
95 is( t::lib::Dates::compare( $seen_patron->lastseen, $now), 0, 'Last seen updated to today if tracking patrons' );
97 $query->param( 'username', $borrower->{cardnumber} );
98 $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
99 is( $reply->{id}, $borrower->{borrowernumber}, "cardnumber and password - Patron authenticated" );
100 is( $reply->{code}, undef, "Error code undef" );
102 $query->param( 'password', 'ilsdi-passworD' );
103 $reply = C4::ILSDI::Services::AuthenticatePatron( $query );
104 is( $reply->{code}, 'PatronNotFound', "cardnumber and wrong password - PatronNotFount" );
105 is( $reply->{id}, undef, "id undef" );
107 $query->param( 'username', 'randomcardnumber1234' );
108 $query->param( 'password', $plain_password );
109 $reply = C4::ILSDI::Services::AuthenticatePatron($query);
110 is( $reply->{code}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound" );
111 is( $reply->{id}, undef, "id undef");
113 $schema->storage->txn_rollback;
117 subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes' => sub {
121 $schema->storage->txn_begin;
123 $schema->resultset( 'Issue' )->delete_all;
124 $schema->resultset( 'Borrower' )->delete_all;
125 $schema->resultset( 'BorrowerAttribute' )->delete_all;
126 $schema->resultset( 'BorrowerAttributeType' )->delete_all;
127 $schema->resultset( 'Category' )->delete_all;
128 $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
129 $schema->resultset( 'Club' )->delete_all;
130 $schema->resultset( 'Branch' )->delete_all;
132 # Configure Koha to enable ILS-DI server and extended attributes:
133 t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
134 t::lib::Mocks::mock_preference( 'ExtendedPatronAttributes', 1 );
136 # Set up a library/branch for our user to belong to:
137 my $lib = $builder->build( {
140 branchcode => 'T_ILSDI',
144 # Create a new category for user to belong to:
145 my $cat = $builder->build( {
146 source => 'Category',
148 category_type => 'A',
149 BlockExpiredPatronOpacActions => -1,
153 # Create a new attribute type:
154 my $attr_type = $builder->build( {
155 source => 'BorrowerAttributeType',
159 authorised_value_category => '',
163 my $attr_type_visible = $builder->build( {
164 source => 'BorrowerAttributeType',
168 authorised_value_category => '',
174 my $brwr = $builder->build( {
175 source => 'Borrower',
177 categorycode => $cat->{'categorycode'},
178 branchcode => $lib->{'branchcode'},
183 my $auth = $builder->build( {
184 source => 'AuthorisedValue',
186 category => $cat->{'categorycode'}
190 # Set the new attribute for our user:
191 my $attr_hidden = $builder->build( {
192 source => 'BorrowerAttribute',
194 borrowernumber => $brwr->{'borrowernumber'},
195 code => $attr_type->{'code'},
196 attribute => '1337 hidden',
199 my $attr_shown = $builder->build( {
200 source => 'BorrowerAttribute',
202 borrowernumber => $brwr->{'borrowernumber'},
203 code => $attr_type_visible->{'code'},
204 attribute => '1337 shown',
208 my $fine = $builder->build(
210 source => 'Accountline',
212 borrowernumber => $brwr->{borrowernumber},
213 debit_type_code => 'OVERDUE',
214 amountoutstanding => 10
219 # Prepare and send web request for IL-SDI server:
220 my $query = CGI->new;
221 $query->param( 'service', 'GetPatronInfo' );
222 $query->param( 'patron_id', $brwr->{'borrowernumber'} );
223 $query->param( 'show_attributes', '1' );
224 $query->param( 'show_fines', '1' );
226 my $reply = C4::ILSDI::Services::GetPatronInfo( $query );
228 # Build a structure for comparison:
230 borrowernumber => $brwr->{borrowernumber},
231 value => $attr_shown->{'attribute'},
232 value_description => $attr_shown->{'attribute'},
237 is( $reply->{'charges'}, '10.00',
238 'The \'charges\' attribute should be correctly filled (bug 17836)' );
240 is( scalar( @{$reply->{fines}->{fine}}), 1, 'There should be only 1 account line');
242 $reply->{fines}->{fine}->[0]->{accountlines_id},
243 $fine->{accountlines_id},
244 "The accountline should be the correct one"
248 is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' );
250 ok( exists $reply->{is_expired}, 'There should be the is_expired information');
253 $schema->storage->txn_rollback;
256 subtest 'LookupPatron test' => sub {
260 $schema->storage->txn_begin;
262 $schema->resultset( 'Issue' )->delete_all;
263 $schema->resultset( 'Borrower' )->delete_all;
264 $schema->resultset( 'BorrowerAttribute' )->delete_all;
265 $schema->resultset( 'BorrowerAttributeType' )->delete_all;
266 $schema->resultset( 'Category' )->delete_all;
267 $schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
268 $schema->resultset( 'Branch' )->delete_all;
270 my $borrower = $builder->build({
271 source => 'Borrower',
274 my $query = CGI->new();
275 my $bad_result = C4::ILSDI::Services::LookupPatron($query);
276 is( $bad_result->{message}, 'PatronNotFound', 'No parameters' );
278 $query->delete_all();
279 $query->param( 'id', $borrower->{firstname} );
280 my $optional_result = C4::ILSDI::Services::LookupPatron($query);
282 $optional_result->{id},
283 $borrower->{borrowernumber},
284 'Valid Firstname only'
287 $query->delete_all();
288 $query->param( 'id', 'ThereIsNoWayThatThisCouldPossiblyBeValid' );
289 my $bad_optional_result = C4::ILSDI::Services::LookupPatron($query);
290 is( $bad_optional_result->{message}, 'PatronNotFound', 'Invalid ID' );
292 foreach my $id_type (
300 $query->delete_all();
301 $query->param( 'id_type', $id_type );
302 $query->param( 'id', $borrower->{$id_type} );
303 my $result = C4::ILSDI::Services::LookupPatron($query);
304 is( $result->{'id'}, $borrower->{borrowernumber}, "Checking $id_type" );
308 $schema->storage->txn_rollback;
311 subtest 'Holds test' => sub {
315 $schema->storage->txn_begin;
317 t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 );
319 my $patron = $builder->build({
320 source => 'Borrower',
323 my $item = $builder->build_sample_item(
329 my $query = CGI->new;
330 $query->param( 'patron_id', $patron->{borrowernumber});
331 $query->param( 'bib_id', $item->biblionumber);
333 my $reply = C4::ILSDI::Services::HoldTitle( $query );
334 is( $reply->{code}, 'damaged', "Item damaged" );
336 $item->damaged(0)->store;
338 my $hold = $builder->build({
341 borrowernumber => $patron->{borrowernumber},
342 biblionumber => $item->biblionumber,
343 itemnumber => $item->itemnumber
347 $reply = C4::ILSDI::Services::HoldTitle( $query );
348 is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" );
350 my $biblio_with_no_item = $builder->build_sample_biblio;
353 $query->param( 'patron_id', $patron->{borrowernumber});
354 $query->param( 'bib_id', $biblio_with_no_item->biblionumber);
356 $reply = C4::ILSDI::Services::HoldTitle( $query );
357 is( $reply->{code}, 'NoItems', 'Biblio has no item' );
359 my $item2 = $builder->build_sample_item(
365 t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' );
366 Koha::CirculationRules->set_rule(
368 categorycode => $patron->{categorycode},
369 itemtype => $item2->{itype},
370 branchcode => $patron->{branchcode},
371 rule_name => 'reservesallowed',
377 $query->param( 'patron_id', $patron->{borrowernumber});
378 $query->param( 'bib_id', $item2->biblionumber);
379 $query->param( 'item_id', $item2->itemnumber);
381 $reply = C4::ILSDI::Services::HoldItem( $query );
382 is( $reply->{code}, 'tooManyReserves', "Too many reserves" );
384 Koha::CirculationRules->set_rule(
386 categorycode => $patron->{categorycode},
387 itemtype => $item2->{itype},
388 branchcode => $patron->{branchcode},
389 rule_name => 'reservesallowed',
395 $query->param( 'patron_id', $patron->{borrowernumber});
396 $query->param( 'bib_id', $item2->biblionumber);
397 $query->param( 'item_id', $item2->itemnumber);
399 $reply = C4::ILSDI::Services::HoldItem( $query );
400 is( $reply->{code}, 'noReservesAllowed', "No reserves allowed" );
402 my $origin_branch = $builder->build(
406 pickup_location => 1,
411 # Adding a holdable item.
412 my $item3 = $builder->build_sample_item(
414 barcode => '123456789',
415 library => $origin_branch->{branchcode}
418 my $item4 = $builder->build_sample_item(
420 biblionumber => $item3->biblionumber,
422 library => $origin_branch->{branchcode}
425 Koha::CirculationRules->set_rule(
427 categorycode => $patron->{categorycode},
428 itemtype => $item3->{itype},
429 branchcode => $patron->{branchcode},
430 rule_name => 'reservesallowed',
436 $query->param( 'patron_id', $patron->{borrowernumber});
437 $query->param( 'bib_id', $item4->biblionumber);
438 $query->param( 'item_id', $item4->itemnumber);
440 $reply = C4::ILSDI::Services::HoldItem( $query );
441 is( $reply->{code}, 'damaged', "Item is damaged" );
443 my $module = Test::MockModule->new('C4::Context');
444 $module->mock('userenv', sub { { patron => $patron } });
445 my $issue = C4::Circulation::AddIssue($patron, $item3->barcode);
446 t::lib::Mocks::mock_preference( 'AllowHoldsOnPatronsPossessions', '0' );
449 $query->param( 'patron_id', $patron->{borrowernumber});
450 $query->param( 'bib_id', $item3->biblionumber);
451 $query->param( 'item_id', $item3->itemnumber);
452 $query->param( 'pickup_location', $origin_branch->{branchcode});
453 $reply = C4::ILSDI::Services::HoldItem( $query );
455 is( $reply->{code}, 'alreadypossession', "Patron has issued same book" );
456 is( $reply->{pickup_location}, undef, "No reserve placed");
458 # Test Patron cannot reserve if expired and BlockExpiredPatronOpacActions
459 my $category = $builder->build({
460 source => 'Category',
461 value => { BlockExpiredPatronOpacActions => -1 }
464 my $branch_1 = $builder->build({ source => 'Branch' })->{ branchcode };
466 my $expired_borrowernumber = Koha::Patron->new({
467 firstname => 'Expired',
469 categorycode => $category->{categorycode},
470 branchcode => $branch_1,
471 dateexpiry => '2000-01-01',
472 })->store->borrowernumber;
474 t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1);
476 my $item5 = $builder->build({
479 biblionumber => $biblio_with_no_item->biblionumber,
485 $query->param( 'patron_id', $expired_borrowernumber);
486 $query->param( 'bib_id', $biblio_with_no_item->biblionumber);
487 $query->param( 'item_id', $item5->{itemnumber});
489 $reply = C4::ILSDI::Services::HoldItem( $query );
490 is( $reply->{code}, 'PatronExpired', "Patron is expired" );
492 $schema->storage->txn_rollback;
495 subtest 'Holds test for branch transfer limits' => sub {
499 $schema->storage->txn_begin;
501 # Test enforement of branch transfer limits
502 t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
503 t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
505 my $patron = $builder->build({
506 source => 'Borrower',
509 my $origin_branch = $builder->build(
513 pickup_location => 1,
517 my $pickup_branch = $builder->build(
521 pickup_location => 1,
526 my $item = $builder->build_sample_item(
528 library => $origin_branch->{branchcode},
532 Koha::CirculationRules->set_rule(
534 categorycode => undef,
537 rule_name => 'reservesallowed',
542 my $limit = Koha::Item::Transfer::Limit->new({
543 toBranch => $pickup_branch->{branchcode},
544 fromBranch => $item->holdingbranch,
545 itemtype => $item->effective_itemtype,
548 my $query = CGI->new;
549 $query->param( 'pickup_location', $pickup_branch->{branchcode} );
550 $query->param( 'patron_id', $patron->{borrowernumber});
551 $query->param( 'bib_id', $item->biblionumber);
552 $query->param( 'item_id', $item->itemnumber);
554 my $reply = C4::ILSDI::Services::HoldItem( $query );
555 is( $reply->{code}, 'cannotBeTransferred', "Item hold, Item cannot be transferred" );
557 $reply = C4::ILSDI::Services::HoldTitle( $query );
558 is( $reply->{code}, 'cannotBeTransferred', "Record hold, Item cannot be transferred" );
560 t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '0' );
562 $reply = C4::ILSDI::Services::HoldItem( $query );
563 is( $reply->{code}, undef, "Item hold, Item can be transferred" );
564 my $hold = Koha::Holds->search({ itemnumber => $item->itemnumber, borrowernumber => $patron->{borrowernumber} })->next;
565 is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' );
567 Koha::Holds->search()->delete();
569 $reply = C4::ILSDI::Services::HoldTitle( $query );
570 is( $reply->{code}, undef, "Record hold, Item con be transferred" );
571 $hold = Koha::Holds->search({ biblionumber => $item->biblionumber, borrowernumber => $patron->{borrowernumber} })->next;
572 is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' );
574 $schema->storage->txn_rollback;
577 subtest 'Holds test with start_date and end_date' => sub {
581 $schema->storage->txn_begin;
583 my $pickup_library = $builder->build_object(
585 class => 'Koha::Libraries',
587 pickup_location => 1,
592 my $patron = $builder->build_object({
593 class => 'Koha::Patrons',
596 my $item = $builder->build_sample_item({ library => $pickup_library->branchcode });
598 Koha::CirculationRules->set_rule(
600 categorycode => undef,
603 rule_name => 'reservesallowed',
608 my $query = CGI->new;
609 $query->param( 'pickup_location', $pickup_library->branchcode );
610 $query->param( 'patron_id', $patron->borrowernumber);
611 $query->param( 'bib_id', $item->biblionumber);
612 $query->param( 'item_id', $item->itemnumber);
613 $query->param( 'start_date', '2020-03-20');
614 $query->param( 'expiry_date', '2020-04-22');
616 my $reply = C4::ILSDI::Services::HoldItem( $query );
617 is ($reply->{pickup_location}, $pickup_library->branchname, "Item hold with date parameters was placed");
618 my $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next();
619 is( $hold->biblionumber, $item->biblionumber, "correct biblionumber");
620 is( $hold->reservedate, '2020-03-20', "Item hold has correct start date" );
621 is( $hold->expirationdate, '2020-04-22', "Item hold has correct end date" );
625 $reply = C4::ILSDI::Services::HoldTitle( $query );
626 is ($reply->{pickup_location}, $pickup_library->branchname, "Record hold with date parameters was placed");
627 $hold = Koha::Holds->search({ biblionumber => $item->biblionumber})->next();
628 is( $hold->biblionumber, $item->biblionumber, "correct biblionumber");
629 is( $hold->reservedate, '2020-03-20', "Record hold has correct start date" );
630 is( $hold->expirationdate, '2020-04-22', "Record hold has correct end date" );
632 $schema->storage->txn_rollback;
635 subtest 'GetRecords' => sub {
639 $schema->storage->txn_begin;
641 t::lib::Mocks::mock_preference( 'ILS-DI', 1 );
643 my $branch1 = $builder->build({
646 my $branch2 = $builder->build({
650 my $item = $builder->build_sample_item(
652 library => $branch1->{branchcode},
656 my $patron = $builder->build({
657 source => 'Borrower',
660 my $issue = $builder->build({
663 itemnumber => $item->itemnumber,
667 my $hold = $builder->build({
670 biblionumber => $item->biblionumber,
674 ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode}, 'Manual');
677 $cgi->param(service => 'GetRecords');
678 $cgi->param(id => $item->biblionumber);
680 my $reply = C4::ILSDI::Services::GetRecords($cgi);
682 my $transfer = $item->get_transfer;
684 datesent => $transfer->datesent,
685 frombranch => $transfer->frombranch,
686 tobranch => $transfer->tobranch,
688 is_deeply($reply->{record}->[0]->{items}->{item}->[0]->{transfer}, $expected,
689 'GetRecords returns transfer informations');
691 # Check informations exposed
692 my $reply_issue = $reply->{record}->[0]->{issues}->{issue}->[0];
693 is($reply_issue->{itemnumber}, $item->itemnumber, 'GetRecords has an issue tag');
694 is($reply_issue->{borrowernumber}, undef, 'GetRecords does not expose borrowernumber in issue tag');
695 is($reply_issue->{surname}, undef, 'GetRecords does not expose surname in issue tag');
696 is($reply_issue->{firstname}, undef, 'GetRecords does not expose firstname in issue tag');
697 is($reply_issue->{cardnumber}, undef, 'GetRecords does not expose cardnumber in issue tag');
698 my $reply_reserve = $reply->{record}->[0]->{reserves}->{reserve}->[0];
699 is($reply_reserve->{biblionumber}, $item->biblionumber, 'GetRecords has a reserve tag');
700 is($reply_reserve->{borrowernumber}, undef, 'GetRecords does not expose borrowernumber in reserve tag');
702 $schema->storage->txn_rollback;
705 subtest 'RenewHold' => sub {
708 $schema->storage->txn_begin;
711 my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
712 my $item = $builder->build_sample_item;
713 $cgi->param( patron_id => $patron->borrowernumber );
714 $cgi->param( item_id => $item->itemnumber );
716 t::lib::Mocks::mock_userenv( { patron => $patron } ); # For AddIssue
717 my $checkout = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode );
720 my $reply = C4::ILSDI::Services::RenewLoan($cgi);
721 is( exists $reply->{date_due}, 1, 'If the item is checked out, the date_due key should exist' );
723 # The item is not checked out
725 $reply = C4::ILSDI::Services::RenewLoan($cgi);
726 is( $reply, undef, 'If the item is not checked out, we should not explode.'); # FIXME We should return an error code instead
728 # The item does not exist
730 $reply = C4::ILSDI::Services::RenewLoan($cgi);
731 is( $reply->{code}, 'RecordNotFound', 'If the item does not exist, RecordNotFound should be returned');
734 $reply = C4::ILSDI::Services::RenewLoan($cgi);
735 is( $reply->{code}, 'PatronNotFound', 'If the patron does not exist, PatronNotFound should be returned');
737 $schema->storage->txn_rollback;
740 subtest 'GetPatronInfo paginated loans' => sub {
743 $schema->storage->txn_begin;
745 my $library = $builder->build_object({
746 class => 'Koha::Libraries',
749 my $item1 = $builder->build_sample_item({ library => $library->branchcode });
750 my $item2 = $builder->build_sample_item({ library => $library->branchcode });
751 my $item3 = $builder->build_sample_item({ library => $library->branchcode });
752 my $patron = $builder->build_object({
753 class => 'Koha::Patrons',
755 branchcode => $library->branchcode,
758 my $module = Test::MockModule->new('C4::Context');
759 $module->mock('userenv', sub { { branch => $library->branchcode } });
760 my $date_due = Koha::DateUtils::dt_from_string()->add(weeks => 2);
761 my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due);
762 my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due );
763 my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due);
764 my $date_due2 = Koha::DateUtils::dt_from_string( $issue2->date_due );
765 my $issue3 = C4::Circulation::AddIssue($patron->unblessed, $item3->barcode, $date_due);
766 my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due );
770 $cgi->param( 'service', 'GetPatronInfo' );
771 $cgi->param( 'patron_id', $patron->borrowernumber );
772 $cgi->param( 'show_loans', '1' );
773 $cgi->param( 'loans_per_page', '2' );
774 $cgi->param( 'loans_page', '1' );
775 my $reply = C4::ILSDI::Services::GetPatronInfo($cgi);
777 is($reply->{total_loans}, 3, 'total_loans == 3');
778 is(scalar @{ $reply->{loans}->{loan} }, 2, 'GetPatronInfo returned only 2 loans');
779 is($reply->{loans}->{loan}->[0]->{itemnumber}, $item3->itemnumber);
780 is($reply->{loans}->{loan}->[1]->{itemnumber}, $item2->itemnumber);
782 $cgi->param( 'loans_page', '2' );
783 $reply = C4::ILSDI::Services::GetPatronInfo($cgi);
785 is($reply->{total_loans}, 3, 'total_loans == 3');
786 is(scalar @{ $reply->{loans}->{loan} }, 1, 'GetPatronInfo returned only 1 loan');
787 is($reply->{loans}->{loan}->[0]->{itemnumber}, $item1->itemnumber);
789 $schema->storage->txn_rollback;