|
Lines 21-27
Link Here
|
| 21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
| 24 |
use Test::More tests => 16; |
24 |
use Test::More tests => 17; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockObject; |
26 |
use Test::MockObject; |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
|
Lines 593-598
subtest 'SC status tests' => sub {
Link Here
|
| 593 |
$schema->storage->txn_rollback; |
593 |
$schema->storage->txn_rollback; |
| 594 |
}; |
594 |
}; |
| 595 |
|
595 |
|
|
|
596 |
subtest 'test_allow_additional_materials_checkout' => sub { |
| 597 |
my $schema = Koha::Database->new->schema; |
| 598 |
$schema->storage->txn_begin; |
| 599 |
|
| 600 |
plan tests => 4; |
| 601 |
|
| 602 |
my $builder = t::lib::TestBuilder->new(); |
| 603 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 604 |
my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 605 |
my ( $response, $findpatron ); |
| 606 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
| 607 |
|
| 608 |
# create some data |
| 609 |
my $patron1 = $builder->build({ |
| 610 |
source => 'Borrower', |
| 611 |
value => { |
| 612 |
password => hash_password( PATRON_PW ), |
| 613 |
}, |
| 614 |
}); |
| 615 |
my $card1 = $patron1->{cardnumber}; |
| 616 |
my $sip_patron1 = C4::SIP::ILS::Patron->new( $card1 ); |
| 617 |
$findpatron = $sip_patron1; |
| 618 |
my $item_object = $builder->build_sample_item({ |
| 619 |
damaged => 0, |
| 620 |
withdrawn => 0, |
| 621 |
itemlost => 0, |
| 622 |
restricted => 0, |
| 623 |
homebranch => $branchcode, |
| 624 |
holdingbranch => $branchcode, |
| 625 |
materials => "This is a materials note", |
| 626 |
}); |
| 627 |
|
| 628 |
my $mockILS = $mocks->{ils}; |
| 629 |
my $server = { ils => $mockILS, account => {} }; |
| 630 |
$mockILS->mock( 'institution', sub { $branchcode; } ); |
| 631 |
$mockILS->mock( 'supports', sub { return; } ); |
| 632 |
$mockILS->mock( 'checkout', sub { |
| 633 |
shift; |
| 634 |
return C4::SIP::ILS->checkout(@_); |
| 635 |
}); |
| 636 |
my $today = dt_from_string; |
| 637 |
t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 }); |
| 638 |
t::lib::Mocks::mock_preference( 'CircConfirmItemParts', '1' ); |
| 639 |
|
| 640 |
my $siprequest = CHECKOUT . 'YN' . siprequestdate($today) . |
| 641 |
siprequestdate( $today->clone->add( days => 1) ) . |
| 642 |
FID_INST_ID . $branchcode . '|'. |
| 643 |
FID_PATRON_ID . $sip_patron1->id . '|' . |
| 644 |
FID_ITEM_ID . $item_object->barcode . '|' . |
| 645 |
FID_TERMINAL_PWD . 'ignored' . '|'; |
| 646 |
undef $response; |
| 647 |
|
| 648 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
| 649 |
$server->{account}->{allow_additional_materials_checkout} = 0; |
| 650 |
$msg->handle_checkout( $server ); |
| 651 |
my $respcode = substr( $response, 0, 2 ); |
| 652 |
check_field( $respcode, $response, FID_SCREEN_MSG, 'Item must be checked out at a circulation desk', 'Check screen msg', 'equals' ); |
| 653 |
is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 0, "Item was not checked out (allow_additional_materials_checkout disabled)"); |
| 654 |
|
| 655 |
$server->{account}->{allow_additional_materials_checkout} = 1; |
| 656 |
$msg->handle_checkout( $server ); |
| 657 |
$respcode = substr( $response, 0, 2 ); |
| 658 |
check_field( $respcode, $response, FID_SCREEN_MSG, 'Item has additional materials: This is a materials note', 'Check screen msg', 'equals' ); |
| 659 |
is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 1, "Item was checked out (allow_additional_materials_checkout enabled"); |
| 660 |
}; |
| 661 |
|
| 596 |
# Here is room for some more subtests |
662 |
# Here is room for some more subtests |
| 597 |
|
663 |
|
| 598 |
# END of main code |
664 |
# END of main code |
| 599 |
- |
|
|