Bug 40960: Fix unit tests
Two unit tests have been moved/replaced to fit the desired behaviour - "patron notified when item set to waiting" -> does not fit the desired behaviour. The desired behaviour for mails/sms is already tested The desired behaviour for prints is changed to "patron not notified if no messaging preference is specified" - "patron not notified a second time (bug 11445)" -> Moved into _koha_notify_reserve tests Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
This commit is contained in:
parent
ba6d2d29f0
commit
24b7f4eacb
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 71;
|
||||
use Test::More tests => 69;
|
||||
use Test::NoWarnings;
|
||||
use Test::MockModule;
|
||||
use Test::Warn;
|
||||
|
|
@ -426,16 +426,7 @@ is(
|
|||
|
||||
# End of tests for bug 9761 (ConfirmFutureHolds)
|
||||
|
||||
# test marking a hold as captured
|
||||
my $hold_notice_count = count_hold_print_messages();
|
||||
ModReserveAffect( $item->itemnumber, $requesters{$branch_1}->borrowernumber, 0 );
|
||||
my $new_count = count_hold_print_messages();
|
||||
is( $new_count, $hold_notice_count + 1, 'patron notified when item set to waiting' );
|
||||
|
||||
# test that duplicate notices aren't generated
|
||||
ModReserveAffect( $item->itemnumber, $requesters{$branch_1}->borrowernumber, 0 );
|
||||
$new_count = count_hold_print_messages();
|
||||
is( $new_count, $hold_notice_count + 1, 'patron not notified a second time (bug 11445)' );
|
||||
|
||||
# avoiding the not_same_branch error
|
||||
t::lib::Mocks::mock_preference( 'IndependentBranches', 0 );
|
||||
|
|
@ -792,7 +783,7 @@ $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
|
|||
|
||||
subtest '_koha_notify_reserve() tests' => sub {
|
||||
|
||||
plan tests => 4;
|
||||
plan tests => 6;
|
||||
|
||||
my $branch = $builder->build_object(
|
||||
{
|
||||
|
|
@ -810,6 +801,12 @@ subtest '_koha_notify_reserve() tests' => sub {
|
|||
holdingbranch => $branch->branchcode
|
||||
}
|
||||
);
|
||||
my $item2 = $builder->build_sample_item(
|
||||
{
|
||||
homebranch => $branch->branchcode,
|
||||
holdingbranch => $branch->branchcode
|
||||
}
|
||||
);
|
||||
|
||||
my $wants_hold_and_email = {
|
||||
wants_digest => '0',
|
||||
|
|
@ -852,6 +849,19 @@ subtest '_koha_notify_reserve() tests' => sub {
|
|||
}
|
||||
);
|
||||
|
||||
my $print_hold_notice = $builder->build(
|
||||
{
|
||||
source => 'Letter',
|
||||
value => {
|
||||
message_transport_type => 'print',
|
||||
branchcode => '',
|
||||
code => 'HOLD',
|
||||
module => 'reserves',
|
||||
lang => 'default',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
my $hold_borrower = $builder->build(
|
||||
{
|
||||
source => 'Borrower',
|
||||
|
|
@ -869,6 +879,13 @@ subtest '_koha_notify_reserve() tests' => sub {
|
|||
biblionumber => $item->biblionumber,
|
||||
}
|
||||
);
|
||||
C4::Reserves::AddReserve(
|
||||
{
|
||||
branchcode => $item->homebranch,
|
||||
borrowernumber => $hold_borrower,
|
||||
biblionumber => $item2->biblionumber,
|
||||
}
|
||||
);
|
||||
|
||||
ModReserveAffect( $item->itemnumber, $hold_borrower, 0 );
|
||||
my $sms_message_address = $schema->resultset('MessageQueue')->search(
|
||||
|
|
@ -897,6 +914,23 @@ subtest '_koha_notify_reserve() tests' => sub {
|
|||
my $email_reply_address = $email->reply_address();
|
||||
is( $email_reply_address, 'branch@reply.to', "Library's reply address is used for reply" );
|
||||
|
||||
$wants_hold_and_email = {
|
||||
wants_digest => '0',
|
||||
transports => {},
|
||||
letter_code => 'HOLD'
|
||||
};
|
||||
$mp = Test::MockModule->new('C4::Members::Messaging');
|
||||
$mp->mock( "GetMessagingPreferences", $wants_hold_and_email );
|
||||
|
||||
my $hold_notice_count = count_hold_print_messages();
|
||||
ModReserveAffect( $item2->itemnumber, $hold_borrower );
|
||||
my $new_count = count_hold_print_messages();
|
||||
is( $new_count, $hold_notice_count, 'patron not notified if no messaging preference is specified' );
|
||||
|
||||
$hold_notice_count = count_hold_print_messages();
|
||||
ModReserveAffect( $item2->itemnumber, $hold_borrower, 0 );
|
||||
$new_count = count_hold_print_messages();
|
||||
is( $new_count, $hold_notice_count, 'patron not notified a second time (bug 11445)' );
|
||||
};
|
||||
|
||||
subtest 'ReservesNeedReturns' => sub {
|
||||
|
|
|
|||
Loading…
Reference in New Issue