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 => 72; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 36-41
use Koha::Caches;
Link Here
|
36 |
use Koha::DateUtils; |
36 |
use Koha::DateUtils; |
37 |
use Koha::Holds; |
37 |
use Koha::Holds; |
38 |
use Koha::Libraries; |
38 |
use Koha::Libraries; |
|
|
39 |
use Koha::Notice::Templates; |
39 |
use Koha::Patron::Categories; |
40 |
use Koha::Patron::Categories; |
40 |
|
41 |
|
41 |
BEGIN { |
42 |
BEGIN { |
Lines 716-721
$cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
Link Here
|
716 |
# we reached the finish |
717 |
# we reached the finish |
717 |
$schema->storage->txn_rollback(); |
718 |
$schema->storage->txn_rollback(); |
718 |
|
719 |
|
|
|
720 |
subtest '_koha_notify_reserve() tests' => sub { |
721 |
|
722 |
plan tests => 2; |
723 |
|
724 |
$schema->storage->txn_begin; |
725 |
|
726 |
my $wants_hold_and_email = { |
727 |
wants_digest => '0', |
728 |
transports => { |
729 |
sms => 'HOLD', |
730 |
email => 'HOLD', |
731 |
}, |
732 |
letter_code => 'HOLD' |
733 |
}; |
734 |
|
735 |
my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); |
736 |
$mp->mock("GetMessagingPreferences",$wants_hold_and_email); |
737 |
|
738 |
my $sms_hold_notice = $builder->build_object({ |
739 |
class => 'Koha::Notice::Templates', |
740 |
value => { |
741 |
message_transport_type => 'sms', |
742 |
branchcode => '', |
743 |
code => 'HOLD', |
744 |
} |
745 |
}); |
746 |
|
747 |
my $hold_borrower = $builder->build({ |
748 |
source => 'Borrower', |
749 |
value => { |
750 |
smsalertnumber=>'5555555555', |
751 |
email=>'a@b.com', |
752 |
} |
753 |
})->{borrowernumber}; |
754 |
|
755 |
my $hold = $builder->build({ |
756 |
source => 'Reserve', |
757 |
value => { |
758 |
borrowernumber=>$hold_borrower |
759 |
} |
760 |
}); |
761 |
|
762 |
ModReserveAffect($hold->{itemnumber}, $hold->{borrowernumber}, 0); |
763 |
my $sms_message_address = $schema->resultset('MessageQueue')->search({ |
764 |
letter_code => 'HOLD', |
765 |
message_transport_type => 'sms', |
766 |
borrowernumber => $hold_borrower, |
767 |
})->next()->to_address(); |
768 |
is($sms_message_address, undef ,"We should not populate the sms message with the sms number, sending will do so"); |
769 |
|
770 |
my $email_message_address = $schema->resultset('MessageQueue')->search({ |
771 |
letter_code => 'HOLD', |
772 |
message_transport_type => 'email', |
773 |
borrowernumber => $hold_borrower, |
774 |
})->next()->to_address(); |
775 |
is($email_message_address, undef ,"We should not populate the hold message with the email address, sending will do so"); |
776 |
|
777 |
$schema->storage->txn_rollback(); |
778 |
|
779 |
}; |
780 |
|
719 |
sub count_hold_print_messages { |
781 |
sub count_hold_print_messages { |
720 |
my $message_count = $dbh->selectall_arrayref(q{ |
782 |
my $message_count = $dbh->selectall_arrayref(q{ |
721 |
SELECT COUNT(*) |
783 |
SELECT COUNT(*) |
722 |
- |
|
|