Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 55; |
21 |
use Test::More tests => 56; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
24 |
use Test::Deep qw( cmp_deeply ); |
24 |
use Test::Deep qw( cmp_deeply ); |
Lines 33-44
use t::lib::TestBuilder;
Link Here
|
33 |
|
33 |
|
34 |
use C4::Accounts; |
34 |
use C4::Accounts; |
35 |
use C4::Calendar qw( new insert_single_holiday insert_week_day_holiday delete_holiday ); |
35 |
use C4::Calendar qw( new insert_single_holiday insert_week_day_holiday delete_holiday ); |
36 |
use C4::Circulation qw( AddIssue AddReturn CanBookBeRenewed GetIssuingCharges AddRenewal GetSoonestRenewDate GetLatestAutoRenewDate LostItem GetUpcomingDueIssues CanBookBeIssued AddIssuingCharge ProcessOfflinePayment transferbook updateWrongTransfer ); |
36 |
use C4::Circulation qw( AddIssue AddReturn CanBookBeRenewed GetIssuingCharges AddRenewal GetSoonestRenewDate GetLatestAutoRenewDate LostItem GetUpcomingDueIssues CanBookBeIssued AddIssuingCharge MarkIssueReturned ProcessOfflinePayment transferbook updateWrongTransfer ); |
37 |
use C4::Biblio; |
37 |
use C4::Biblio; |
38 |
use C4::Items qw( ModItemTransfer ); |
38 |
use C4::Items qw( ModItemTransfer ); |
39 |
use C4::Log; |
39 |
use C4::Log; |
40 |
use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ModReserveAffect CheckReserves GetOtherReserves ); |
40 |
use C4::Reserves qw( AddReserve ModReserve ModReserveCancelAll ModReserveAffect CheckReserves GetOtherReserves ); |
41 |
use C4::Overdues qw( CalcFine UpdateFine get_chargeable_units ); |
41 |
use C4::Overdues qw( CalcFine UpdateFine get_chargeable_units ); |
|
|
42 |
use C4::Members::Messaging qw( SetMessagingPreference ); |
42 |
use Koha::DateUtils; |
43 |
use Koha::DateUtils; |
43 |
use Koha::Database; |
44 |
use Koha::Database; |
44 |
use Koha::Items; |
45 |
use Koha::Items; |
Lines 51-56
use Koha::Subscriptions;
Link Here
|
51 |
use Koha::Account::Lines; |
52 |
use Koha::Account::Lines; |
52 |
use Koha::Account::Offsets; |
53 |
use Koha::Account::Offsets; |
53 |
use Koha::ActionLogs; |
54 |
use Koha::ActionLogs; |
|
|
55 |
use Koha::Notice::Messages; |
54 |
|
56 |
|
55 |
sub set_userenv { |
57 |
sub set_userenv { |
56 |
my ( $library ) = @_; |
58 |
my ( $library ) = @_; |
Lines 4916-4921
subtest "updateWrongTransfer tests" => sub {
Link Here
|
4916 |
is( $original_transfer->cancellation_reason, 'WrongTransfer', "Original transfer cancellation reason is 'WrongTransfer'"); |
4918 |
is( $original_transfer->cancellation_reason, 'WrongTransfer', "Original transfer cancellation reason is 'WrongTransfer'"); |
4917 |
}; |
4919 |
}; |
4918 |
|
4920 |
|
|
|
4921 |
subtest "SendCirculationAlert" => sub { |
4922 |
plan tests => 2; |
4923 |
|
4924 |
# Setup branch, borrowr, and notice |
4925 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
4926 |
set_userenv( $library->unblessed); |
4927 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
4928 |
C4::Members::Messaging::SetMessagingPreference({ |
4929 |
borrowernumber => $patron->id, |
4930 |
message_transport_types => ['email'], |
4931 |
message_attribute_id => 5 |
4932 |
}); |
4933 |
my $item = $builder->build_sample_item(); |
4934 |
my $checkin_notice = $builder->build_object({ |
4935 |
class => 'Koha::Notice::Templates', |
4936 |
value =>{ |
4937 |
module => 'circulation', |
4938 |
code => 'CHECKIN', |
4939 |
branchcode => $library->branchcode, |
4940 |
name => 'Test Checkin', |
4941 |
is_html => 0, |
4942 |
content => "Checkins:\n----\n[% biblio.title %]-[% old_checkout.issue_id %]\n----Thank you.", |
4943 |
message_transport_type => 'email', |
4944 |
lang => 'default' |
4945 |
} |
4946 |
})->store; |
4947 |
|
4948 |
# Checkout an item, mark it returned, generate a notice |
4949 |
my $issue_1 = AddIssue( $patron->unblessed, $item->barcode); |
4950 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
4951 |
C4::Circulation::SendCirculationAlert({ |
4952 |
type => 'CHECKIN', |
4953 |
item => $item->unblessed, |
4954 |
borrower => $patron->unblessed, |
4955 |
branch => $library->branchcode, |
4956 |
issue => $issue_1 |
4957 |
}); |
4958 |
my $notice = Koha::Notice::Messages->find({ borrowernumber => $patron->id, letter_code => 'CHECKIN' }); |
4959 |
is($notice->content,"Checkins:\n".$item->biblio->title."-".$issue_1->id."\nThank you.", 'Letter generated with expected output on first checkin' ); |
4960 |
|
4961 |
# Checkout an item, mark it returned, generate a notice |
4962 |
my $issue_2 = AddIssue( $patron->unblessed, $item->barcode); |
4963 |
MarkIssueReturned( $patron->borrowernumber, $item->itemnumber, undef, 0, { skip_record_index => 1} ); |
4964 |
C4::Circulation::SendCirculationAlert({ |
4965 |
type => 'CHECKIN', |
4966 |
item => $item->unblessed, |
4967 |
borrower => $patron->unblessed, |
4968 |
branch => $library->branchcode, |
4969 |
issue => $issue_2 |
4970 |
}); |
4971 |
$notice->discard_changes(); |
4972 |
is($notice->content,"Checkins:\n".$item->biblio->title."-".$issue_1->id."\n".$item->biblio->title."-".$issue_2->id."\nThank you.", 'Letter appended with expected output on second checkin' ); |
4973 |
|
4974 |
}; |
4975 |
|
4919 |
$schema->storage->txn_rollback; |
4976 |
$schema->storage->txn_rollback; |
4920 |
C4::Context->clear_syspref_cache(); |
4977 |
C4::Context->clear_syspref_cache(); |
4921 |
$branches = Koha::Libraries->search(); |
4978 |
$branches = Koha::Libraries->search(); |
4922 |
- |
|
|