|
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 2032-2038
subtest 'anonymize' => sub {
Link Here
|
| 2032 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
2032 |
is( $patron2->firstname, undef, 'First name patron2 cleared' ); |
| 2033 |
}; |
2033 |
}; |
| 2034 |
|
2034 |
|
| 2035 |
subtest 'send_notice' => sub { |
2035 |
subtest 'queue_notice' => sub { |
| 2036 |
plan tests => 11; |
2036 |
plan tests => 11; |
| 2037 |
|
2037 |
|
| 2038 |
my $dbh = C4::Context->dbh; |
2038 |
my $dbh = C4::Context->dbh; |
|
Lines 2079-2104
subtest 'send_notice' => sub {
Link Here
|
| 2079 |
}; |
2079 |
}; |
| 2080 |
my @mtts = ('email'); |
2080 |
my @mtts = ('email'); |
| 2081 |
|
2081 |
|
| 2082 |
is( $patron->send_notice(), undef, "Nothing is done if no params passed"); |
2082 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
| 2083 |
is( $patron->send_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2083 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
| 2084 |
is_deeply( |
2084 |
is_deeply( |
| 2085 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2085 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
| 2086 |
{sent => ['email'] }, "Email sent" |
2086 |
{sent => ['email'] }, "Email sent" |
| 2087 |
); |
2087 |
); |
| 2088 |
$patron->email("")->store; |
2088 |
$patron->email("")->store; |
| 2089 |
is_deeply( |
2089 |
is_deeply( |
| 2090 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2090 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
| 2091 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2091 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
| 2092 |
); |
2092 |
); |
| 2093 |
push @mtts, 'sms'; |
2093 |
push @mtts, 'sms'; |
| 2094 |
is_deeply( |
2094 |
is_deeply( |
| 2095 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2095 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
| 2096 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2096 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
| 2097 |
); |
2097 |
); |
| 2098 |
$patron->smsalertnumber("")->store; |
2098 |
$patron->smsalertnumber("")->store; |
| 2099 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2099 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
| 2100 |
is_deeply( |
2100 |
is_deeply( |
| 2101 |
$patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2101 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
| 2102 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2102 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
| 2103 |
); |
2103 |
); |
| 2104 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2104 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
|
Lines 2108-2123
subtest 'send_notice' => sub {
Link Here
|
| 2108 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
2108 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
| 2109 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
2109 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
| 2110 |
|
2110 |
|
| 2111 |
is( $patron->send_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2111 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
| 2112 |
|
2112 |
|
| 2113 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2113 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
| 2114 |
is_deeply( |
2114 |
is_deeply( |
| 2115 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2115 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
| 2116 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2116 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
| 2117 |
); |
2117 |
); |
| 2118 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2118 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
| 2119 |
is_deeply( |
2119 |
is_deeply( |
| 2120 |
$patron->send_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
2120 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled', test_mode => 1 }), |
| 2121 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
2121 |
{sent => ['email'] }, "Report that email sent when using borrower preferences in test_mode" |
| 2122 |
); |
2122 |
); |
| 2123 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
2123 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter,"Count of queued notices not increased in test mode"); |
| 2124 |
- |
|
|