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

(-)a/t/db_dependent/Reserves.t (-12 / +45 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 71;
20
use Test::More tests => 69;
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::MockModule;
22
use Test::MockModule;
23
use Test::Warn;
23
use Test::Warn;
Lines 426-441 is( Link Here
426
426
427
# End of tests for bug 9761 (ConfirmFutureHolds)
427
# End of tests for bug 9761 (ConfirmFutureHolds)
428
428
429
# test marking a hold as captured
430
my $hold_notice_count = count_hold_print_messages();
431
ModReserveAffect( $item->itemnumber, $requesters{$branch_1}->borrowernumber, 0 );
429
ModReserveAffect( $item->itemnumber, $requesters{$branch_1}->borrowernumber, 0 );
432
my $new_count = count_hold_print_messages();
433
is( $new_count, $hold_notice_count + 1, 'patron notified when item set to waiting' );
434
435
# test that duplicate notices aren't generated
436
ModReserveAffect( $item->itemnumber, $requesters{$branch_1}->borrowernumber, 0 );
437
$new_count = count_hold_print_messages();
438
is( $new_count, $hold_notice_count + 1, 'patron not notified a second time (bug 11445)' );
439
430
440
# avoiding the not_same_branch error
431
# avoiding the not_same_branch error
441
t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
432
t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
Lines 792-798 $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); Link Here
792
783
793
subtest '_koha_notify_reserve() tests' => sub {
784
subtest '_koha_notify_reserve() tests' => sub {
794
785
795
    plan tests => 4;
786
    plan tests => 6;
796
787
797
    my $branch = $builder->build_object(
788
    my $branch = $builder->build_object(
798
        {
789
        {
Lines 810-815 subtest '_koha_notify_reserve() tests' => sub { Link Here
810
            holdingbranch => $branch->branchcode
801
            holdingbranch => $branch->branchcode
811
        }
802
        }
812
    );
803
    );
804
    my $item2 = $builder->build_sample_item(
805
        {
806
            homebranch    => $branch->branchcode,
807
            holdingbranch => $branch->branchcode
808
        }
809
    );
813
810
814
    my $wants_hold_and_email = {
811
    my $wants_hold_and_email = {
815
        wants_digest => '0',
812
        wants_digest => '0',
Lines 852-857 subtest '_koha_notify_reserve() tests' => sub { Link Here
852
        }
849
        }
853
    );
850
    );
854
851
852
    my $print_hold_notice = $builder->build(
853
        {
854
            source => 'Letter',
855
            value  => {
856
                message_transport_type => 'print',
857
                branchcode             => '',
858
                code                   => 'HOLD',
859
                module                 => 'reserves',
860
                lang                   => 'default',
861
            }
862
        }
863
    );
864
855
    my $hold_borrower = $builder->build(
865
    my $hold_borrower = $builder->build(
856
        {
866
        {
857
            source => 'Borrower',
867
            source => 'Borrower',
Lines 869-874 subtest '_koha_notify_reserve() tests' => sub { Link Here
869
            biblionumber   => $item->biblionumber,
879
            biblionumber   => $item->biblionumber,
870
        }
880
        }
871
    );
881
    );
882
    C4::Reserves::AddReserve(
883
        {
884
            branchcode     => $item->homebranch,
885
            borrowernumber => $hold_borrower,
886
            biblionumber   => $item2->biblionumber,
887
        }
888
    );
872
889
873
    ModReserveAffect( $item->itemnumber, $hold_borrower, 0 );
890
    ModReserveAffect( $item->itemnumber, $hold_borrower, 0 );
874
    my $sms_message_address = $schema->resultset('MessageQueue')->search(
891
    my $sms_message_address = $schema->resultset('MessageQueue')->search(
Lines 897-902 subtest '_koha_notify_reserve() tests' => sub { Link Here
897
    my $email_reply_address = $email->reply_address();
914
    my $email_reply_address = $email->reply_address();
898
    is( $email_reply_address, 'branch@reply.to', "Library's reply address is used for reply" );
915
    is( $email_reply_address, 'branch@reply.to', "Library's reply address is used for reply" );
899
916
917
    $wants_hold_and_email = {
918
        wants_digest => '0',
919
        transports   => {},
920
        letter_code  => 'HOLD'
921
    };
922
    $mp = Test::MockModule->new('C4::Members::Messaging');
923
    $mp->mock( "GetMessagingPreferences", $wants_hold_and_email );
924
925
    my $hold_notice_count = count_hold_print_messages();
926
    ModReserveAffect( $item2->itemnumber, $hold_borrower );
927
    my $new_count = count_hold_print_messages();
928
    is( $new_count, $hold_notice_count, 'patron not notified if no messaging preference is specified' );
929
930
    $hold_notice_count = count_hold_print_messages();
931
    ModReserveAffect( $item2->itemnumber, $hold_borrower, 0 );
932
    $new_count = count_hold_print_messages();
933
    is( $new_count, $hold_notice_count, 'patron not notified a second time (bug 11445)' );
900
};
934
};
901
935
902
subtest 'ReservesNeedReturns' => sub {
936
subtest 'ReservesNeedReturns' => sub {
903
- 

Return to bug 40960