|
Lines 19-30
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 9; |
| 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 ); |
27 |
use C4::Items qw( ModItemTransfer ); |
|
|
28 |
use C4::Circulation; |
| 28 |
|
29 |
|
| 29 |
use Koha::AuthUtils; |
30 |
use Koha::AuthUtils; |
| 30 |
|
31 |
|
|
Lines 631-633
subtest 'RenewHold' => sub {
Link Here
|
| 631 |
|
632 |
|
| 632 |
$schema->storage->txn_rollback; |
633 |
$schema->storage->txn_rollback; |
| 633 |
}; |
634 |
}; |
| 634 |
- |
635 |
|
|
|
636 |
subtest 'GetPatronInfo paginated loans' => sub { |
| 637 |
plan tests => 7; |
| 638 |
|
| 639 |
$schema->storage->txn_begin; |
| 640 |
|
| 641 |
my $library = $builder->build_object({ |
| 642 |
class => 'Koha::Libraries', |
| 643 |
}); |
| 644 |
|
| 645 |
my $item1 = $builder->build_sample_item({ library => $library->branchcode }); |
| 646 |
my $item2 = $builder->build_sample_item({ library => $library->branchcode }); |
| 647 |
my $item3 = $builder->build_sample_item({ library => $library->branchcode }); |
| 648 |
my $patron = $builder->build_object({ |
| 649 |
class => 'Koha::Patrons', |
| 650 |
value => { |
| 651 |
branchcode => $library->branchcode, |
| 652 |
}, |
| 653 |
}); |
| 654 |
my $module = new Test::MockModule('C4::Context'); |
| 655 |
$module->mock('userenv', sub { { branch => $library->branchcode } }); |
| 656 |
my $date_due = DateTime->now->add(weeks => 2); |
| 657 |
my $issue1 = C4::Circulation::AddIssue($patron->unblessed, $item1->barcode, $date_due); |
| 658 |
my $date_due1 = Koha::DateUtils::dt_from_string( $issue1->date_due ); |
| 659 |
my $issue2 = C4::Circulation::AddIssue($patron->unblessed, $item2->barcode, $date_due); |
| 660 |
my $date_due2 = Koha::DateUtils::dt_from_string( $issue2->date_due ); |
| 661 |
my $issue3 = C4::Circulation::AddIssue($patron->unblessed, $item3->barcode, $date_due); |
| 662 |
my $date_due3 = Koha::DateUtils::dt_from_string( $issue3->date_due ); |
| 663 |
|
| 664 |
my $cgi = new CGI; |
| 665 |
|
| 666 |
$cgi->param( 'service', 'GetPatronInfo' ); |
| 667 |
$cgi->param( 'patron_id', $patron->borrowernumber ); |
| 668 |
$cgi->param( 'show_loans', '1' ); |
| 669 |
$cgi->param( 'loans_per_page', '2' ); |
| 670 |
$cgi->param( 'loans_page', '1' ); |
| 671 |
my $reply = C4::ILSDI::Services::GetPatronInfo($cgi); |
| 672 |
|
| 673 |
is($reply->{total_loans}, 3, 'total_loans == 3'); |
| 674 |
is(scalar @{ $reply->{loans}->{loan} }, 2, 'GetPatronInfo returned only 2 loans'); |
| 675 |
is($reply->{loans}->{loan}->[0]->{itemnumber}, $item3->itemnumber); |
| 676 |
is($reply->{loans}->{loan}->[1]->{itemnumber}, $item2->itemnumber); |
| 677 |
|
| 678 |
$cgi->param( 'loans_page', '2' ); |
| 679 |
$reply = C4::ILSDI::Services::GetPatronInfo($cgi); |
| 680 |
|
| 681 |
is($reply->{total_loans}, 3, 'total_loans == 3'); |
| 682 |
is(scalar @{ $reply->{loans}->{loan} }, 1, 'GetPatronInfo returned only 1 loan'); |
| 683 |
is($reply->{loans}->{loan}->[0]->{itemnumber}, $item1->itemnumber); |
| 684 |
|
| 685 |
$schema->storage->txn_rollback; |
| 686 |
}; |