Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 43; |
22 |
use Test::More tests => 44; |
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 2354-2378
subtest 'queue_notice' => sub {
Link Here
|
2354 |
|
2354 |
|
2355 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
2355 |
is( $patron->queue_notice(), undef, "Nothing is done if no params passed"); |
2356 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2356 |
is( $patron->queue_notice({ letter_params => $letter_params }),undef, "Nothing done if only letter"); |
2357 |
is_deeply( |
2357 |
cmp_deeply( |
2358 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2358 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2359 |
{sent => ['email'] }, "Email sent" |
2359 |
{sent => ['email'], message_ids => [ignore()] }, "Email sent" |
2360 |
); |
2360 |
); |
2361 |
$patron->email("")->store; |
2361 |
$patron->email("")->store; |
2362 |
is_deeply( |
2362 |
cmp_deeply( |
2363 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2363 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2364 |
{sent => ['print'],fallback => ['email']}, "Email fallsback to print if no email" |
2364 |
{sent => ['print'],fallback => ['email'], message_ids => [ignore()]}, "Email fallsback to print if no email" |
2365 |
); |
2365 |
); |
2366 |
push @mtts, 'sms'; |
2366 |
push @mtts, 'sms'; |
2367 |
is_deeply( |
2367 |
cmp_deeply( |
2368 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2368 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2369 |
{sent => ['print','sms'],fallback => ['email']}, "Email fallsback to print if no email, sms sent" |
2369 |
{sent => ['print','sms'],fallback => ['email'], message_ids => [ignore(), ignore()]}, "Email fallsback to print if no email, sms sent" |
2370 |
); |
2370 |
); |
2371 |
$patron->smsalertnumber("")->store; |
2371 |
$patron->smsalertnumber("")->store; |
2372 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2372 |
my $counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2373 |
is_deeply( |
2373 |
cmp_deeply( |
2374 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2374 |
$patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts }), |
2375 |
{sent => ['print'],fallback => ['email','sms']}, "Email fallsback to print if no emai, sms fallsback to print if no sms, only one print sent" |
2375 |
{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" |
2376 |
); |
2376 |
); |
2377 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2377 |
is( Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count, $counter+1,"Count of queued notices went up by one"); |
2378 |
|
2378 |
|
Lines 2384-2392
subtest 'queue_notice' => sub {
Link Here
|
2384 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2384 |
is( $patron->queue_notice({ letter_params => $letter_params, message_transports => \@mtts, message_name => 'Hold_Filled' }),undef, "Nothing done if transports and name sent"); |
2385 |
|
2385 |
|
2386 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2386 |
$patron->email(q|awesome@ismymiddle.name|)->store; |
2387 |
is_deeply( |
2387 |
cmp_deeply( |
2388 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2388 |
$patron->queue_notice({ letter_params => $letter_params, message_name => 'Hold_Filled' }), |
2389 |
{sent => ['email'] }, "Email sent when using borrower preferences" |
2389 |
{sent => ['email'], message_ids => [ignore()] }, "Email sent when using borrower preferences" |
2390 |
); |
2390 |
); |
2391 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2391 |
$counter = Koha::Notice::Messages->search({borrowernumber => $patron->borrowernumber })->count; |
2392 |
is_deeply( |
2392 |
is_deeply( |
2393 |
- |
|
|