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

(-)a/t/db_dependent/SIP/Message.t (-2 / +67 lines)
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 577-582 subtest 'SC status tests' => sub { Link Here
577
577
578
};
578
};
579
579
580
subtest 'test_allow_additional_materials_checkout' => sub {
581
    my $schema = Koha::Database->new->schema;
582
    $schema->storage->txn_begin;
583
584
    plan tests => 4;
585
586
    my $builder = t::lib::TestBuilder->new();
587
    my $branchcode  = $builder->build({ source => 'Branch' })->{branchcode};
588
    my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode};
589
    my ( $response, $findpatron );
590
    my $mocks = create_mocks( \$response, \$findpatron, \$branchcode );
591
592
    # create some data
593
    my $patron1 = $builder->build({
594
        source => 'Borrower',
595
        value  => {
596
            password => hash_password( PATRON_PW ),
597
        },
598
    });
599
    my $card1 = $patron1->{cardnumber};
600
    my $sip_patron1 = C4::SIP::ILS::Patron->new( $card1 );
601
    $findpatron = $sip_patron1;
602
    my $item_object = $builder->build_sample_item({
603
        damaged => 0,
604
        withdrawn => 0,
605
        itemlost => 0,
606
        restricted => 0,
607
        homebranch => $branchcode,
608
        holdingbranch => $branchcode,
609
        materials => "This is a materials note",
610
    });
611
612
    my $mockILS = $mocks->{ils};
613
    my $server = { ils => $mockILS, account => {} };
614
    $mockILS->mock( 'institution', sub { $branchcode; } );
615
    $mockILS->mock( 'supports', sub { return; } );
616
    $mockILS->mock( 'checkout', sub {
617
        shift;
618
        return C4::SIP::ILS->checkout(@_);
619
    });
620
    my $today = dt_from_string;
621
    t::lib::Mocks::mock_userenv({ branchcode => $branchcode, flags => 1 });
622
    t::lib::Mocks::mock_preference( 'CircConfirmItemParts',  '1' );
623
624
    my $siprequest = CHECKOUT . 'YN' . siprequestdate($today) .
625
    siprequestdate( $today->clone->add( days => 1) ) .
626
    FID_INST_ID . $branchcode . '|'.
627
    FID_PATRON_ID . $sip_patron1->id . '|' .
628
    FID_ITEM_ID . $item_object->barcode . '|' .
629
    FID_TERMINAL_PWD . 'ignored' . '|';
630
    undef $response;
631
632
    my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 );
633
    $server->{account}->{allow_additional_materials_checkout} = 0;
634
    $msg->handle_checkout( $server );
635
    my $respcode = substr( $response, 0, 2 );
636
    check_field( $respcode, $response, FID_SCREEN_MSG, 'Item must be checked out at a circulation desk', 'Check screen msg', 'equals' );
637
    is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 0, "Item was not checked out (allow_additional_materials_checkout disabled)");
638
639
    $server->{account}->{allow_additional_materials_checkout} = 1;
640
    $msg->handle_checkout( $server );
641
    $respcode = substr( $response, 0, 2 );
642
    check_field( $respcode, $response, FID_SCREEN_MSG, 'Item has additional materials: This is a materials note', 'Check screen msg', 'equals' );
643
    is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 1, "Item was checked out (allow_additional_materials_checkout enabled");
644
};
645
580
# Here is room for some more subtests
646
# Here is room for some more subtests
581
647
582
# END of main code
648
# END of main code
583
- 

Return to bug 34153