Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 41; |
22 |
use Test::More tests => 42; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
Lines 1969-1975
subtest 'anonymize' => sub {
Link Here
|
1969 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1969 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
1970 |
}; |
1970 |
}; |
1971 |
|
1971 |
|
1972 |
subtest 'send_notice' => sub { |
1972 |
subtest 'queue_notice' => sub { |
1973 |
plan tests => 11; |
1973 |
plan tests => 11; |
1974 |
|
1974 |
|
1975 |
my $dbh = C4::Context->dbh; |
1975 |
my $dbh = C4::Context->dbh; |
Lines 2016-2041
subtest 'send_notice' => sub {
Link Here
|
2016 |
}; |
2016 |
}; |
2017 |
my @mtts = ('email'); |
2017 |
my @mtts = ('email'); |
2018 |
|
2018 |
|
2019 |
is( $patron->send_notice(), undef, "Nothing is done if no params passed"); |
2019 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
2020 |
is( $patron->send_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2020 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2021 |
is_deeply( |
2021 |
is_deeply( |
2022 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2022 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2023 |
{sent => ['email'] }, "Email sent" |
2023 |
{sent => ['email'] }, "Email sent" |
2024 |
); |
2024 |
); |
2025 |
$patron->email("")->store; |
2025 |
$patron->email("")->store; |
2026 |
is_deeply( |
2026 |
is_deeply( |
2027 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2027 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2028 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2028 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2029 |
); |
2029 |
); |
2030 |
push @mtts, 'sms'; |
2030 |
push @mtts, 'sms'; |
2031 |
is_deeply( |
2031 |
is_deeply( |
2032 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2032 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2033 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2033 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2034 |
); |
2034 |
); |
2035 |
$patron->smsalertnumber("")->store; |
2035 |
$patron->smsalertnumber("")->store; |
2036 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2036 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2037 |
is_deeply( |
2037 |
is_deeply( |
2038 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2038 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2039 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2039 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2040 |
); |
2040 |
); |
2041 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2041 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
Lines 2045-2060
subtest 'send_notice' => sub {
Link Here
|
2045 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
2045 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
2046 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
2046 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
2047 |
|
2047 |
|
2048 |
is( $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2048 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2049 |
|
2049 |
|
2050 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2050 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2051 |
is_deeply( |
2051 |
is_deeply( |
2052 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2052 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2053 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2053 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2054 |
); |
2054 |
); |
2055 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2055 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2056 |
is_deeply( |
2056 |
is_deeply( |
2057 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
2057 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
2058 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
2058 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
2059 |
); |
2059 |
); |
2060 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2060 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2061 |
- |
|
|