Lines 20-25
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 45; |
22 |
use Test::More tests => 45; |
|
|
23 |
use Test::Deep qw( cmp_deeply ignore ); |
23 |
use Test::Warn; |
24 |
use Test::Warn; |
24 |
use Test::Exception; |
25 |
use Test::Exception; |
25 |
use Test::MockModule; |
26 |
use Test::MockModule; |
Lines 2275-2299
subtest 'queue_notice' => sub {
Link Here
|
2275 |
|
2276 |
|
2276 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
2277 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
2277 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2278 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2278 |
is_deeply( |
2279 |
cmp_deeply( |
2279 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2280 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2280 |
{sent => ['email'] }, "Email sent" |
2281 |
{sent => ['email'], message_ids => [ignore()] }, "Email sent" |
2281 |
); |
2282 |
); |
2282 |
$patron->email("")->store; |
2283 |
$patron->email("")->store; |
2283 |
is_deeply( |
2284 |
cmp_deeply( |
2284 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2285 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2285 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2286 |
{sent => ['print'],fallback => ['email'], message_ids => [ignore()]}, "Email fallsback to print if no email" |
2286 |
); |
2287 |
); |
2287 |
push @mtts, 'sms'; |
2288 |
push @mtts, 'sms'; |
2288 |
is_deeply( |
2289 |
cmp_deeply( |
2289 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2290 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2290 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2291 |
{sent => ['print','sms'],fallback => ['email'], message_ids => [ignore(), ignore()]}, "Email fallsback to print if no email, sms sent" |
2291 |
); |
2292 |
); |
2292 |
$patron->smsalertnumber("")->store; |
2293 |
$patron->smsalertnumber("")->store; |
2293 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2294 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2294 |
is_deeply( |
2295 |
cmp_deeply( |
2295 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2296 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2296 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2297 |
{sent => ['print'],fallback => ['email','sms'], message_ids => [ignore()]}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2297 |
); |
2298 |
); |
2298 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2299 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2299 |
|
2300 |
|
Lines 2305-2313
subtest 'queue_notice' => sub {
Link Here
|
2305 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2306 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2306 |
|
2307 |
|
2307 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2308 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2308 |
is_deeply( |
2309 |
cmp_deeply( |
2309 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2310 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2310 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2311 |
{sent => ['email'], message_ids => [ignore()] }, "Email sent when using borrower preferences" |
2311 |
); |
2312 |
); |
2312 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2313 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2313 |
is_deeply( |
2314 |
is_deeply( |
2314 |
- |
|
|