|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
| 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; |
|
Lines 596-598
subtest 'GetRecords' => sub {
Link Here
|
| 596 |
|
596 |
|
| 597 |
$schema->storage->txn_rollback; |
597 |
$schema->storage->txn_rollback; |
| 598 |
}; |
598 |
}; |
| 599 |
- |
599 |
|
|
|
600 |
subtest 'RenewHold' => sub { |
| 601 |
plan tests => 4; |
| 602 |
|
| 603 |
$schema->storage->txn_begin; |
| 604 |
|
| 605 |
my $cgi = new CGI; |
| 606 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 607 |
my $item = $builder->build_object( { class => 'Koha::Items' } ); |
| 608 |
$cgi->param( patron_id => $patron->borrowernumber ); |
| 609 |
$cgi->param( item_id => $item->itemnumber ); |
| 610 |
|
| 611 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); # For AddIssue |
| 612 |
my $checkout = C4::Circulation::AddIssue( $patron->unblessed, $item->barcode ); |
| 613 |
|
| 614 |
# Everything is ok |
| 615 |
my $reply = C4::ILSDI::Services::RenewLoan($cgi); |
| 616 |
is( exists $reply->{date_due}, 1, 'If the item is checked out, the date_due key should exist' ); |
| 617 |
|
| 618 |
# The item is not checked out |
| 619 |
$checkout->delete; |
| 620 |
$reply = C4::ILSDI::Services::RenewLoan($cgi); |
| 621 |
is( $reply, undef, 'If the item is not checked out, we should not explode.'); # FIXME We should return an error code instead |
| 622 |
|
| 623 |
# The item does not exist |
| 624 |
$item->delete; |
| 625 |
$reply = C4::ILSDI::Services::RenewLoan($cgi); |
| 626 |
is( $reply->{code}, 'RecordNotFound', 'If the item does not exist, RecordNotFound should be returned'); |
| 627 |
|
| 628 |
$patron->delete; |
| 629 |
$reply = C4::ILSDI::Services::RenewLoan($cgi); |
| 630 |
is( $reply->{code}, 'PatronNotFound', 'If the patron does not exist, PatronNotFound should be returned'); |
| 631 |
|
| 632 |
$schema->storage->txn_rollback; |
| 633 |
}; |