Lines 70-80
my $borrowernumber = AddMember(
Link Here
|
70 |
categorycode => $patron_category, |
70 |
categorycode => $patron_category, |
71 |
branchcode => $library->{branchcode}, |
71 |
branchcode => $library->{branchcode}, |
72 |
dateofbirth => $date, |
72 |
dateofbirth => $date, |
|
|
73 |
smsalertnumber => undef, |
73 |
); |
74 |
); |
74 |
|
75 |
|
75 |
my $marc_record = MARC::Record->new; |
76 |
my $marc_record = MARC::Record->new; |
76 |
my( $biblionumber, $biblioitemnumber ) = AddBiblio( $marc_record, '' ); |
77 |
my( $biblionumber, $biblioitemnumber ) = AddBiblio( $marc_record, '' ); |
77 |
|
78 |
|
|
|
79 |
|
80 |
|
78 |
# GetMessageTransportTypes |
81 |
# GetMessageTransportTypes |
79 |
my $mtts = C4::Letters::GetMessageTransportTypes(); |
82 |
my $mtts = C4::Letters::GetMessageTransportTypes(); |
80 |
is( @$mtts, 0, 'GetMessageTransportTypes returns the correct number of message types' ); |
83 |
is( @$mtts, 0, 'GetMessageTransportTypes returns the correct number of message types' ); |
Lines 92-98
is( C4::Letters::EnqueueLetter(), undef, 'EnqueueLetter without argument returns
Link Here
|
92 |
my $my_message = { |
95 |
my $my_message = { |
93 |
borrowernumber => $borrowernumber, |
96 |
borrowernumber => $borrowernumber, |
94 |
message_transport_type => 'sms', |
97 |
message_transport_type => 'sms', |
95 |
to_address => 'to@example.com', |
98 |
to_address => undef, |
96 |
from_address => 'from@example.com', |
99 |
from_address => 'from@example.com', |
97 |
}; |
100 |
}; |
98 |
my $message_id = C4::Letters::EnqueueLetter($my_message); |
101 |
my $message_id = C4::Letters::EnqueueLetter($my_message); |
Lines 131-137
is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin
Link Here
|
131 |
# SendQueuedMessages |
134 |
# SendQueuedMessages |
132 |
my $messages_processed = C4::Letters::SendQueuedMessages(); |
135 |
my $messages_processed = C4::Letters::SendQueuedMessages(); |
133 |
is($messages_processed, 1, 'all queued messages processed'); |
136 |
is($messages_processed, 1, 'all queued messages processed'); |
134 |
|
|
|
135 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
137 |
$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); |
136 |
is( |
138 |
is( |
137 |
$messages->[0]->{status}, |
139 |
$messages->[0]->{status}, |
Lines 279-284
my $prepared_letter = GetPreparedLetter((
Link Here
|
279 |
)); |
281 |
)); |
280 |
my $retrieved_library = Koha::Libraries->find($library->{branchcode}); |
282 |
my $retrieved_library = Koha::Libraries->find($library->{branchcode}); |
281 |
my $my_title_letter = $retrieved_library->branchname . qq| - $substitute->{status}|; |
283 |
my $my_title_letter = $retrieved_library->branchname . qq| - $substitute->{status}|; |
|
|
284 |
my $biblio_timestamp = dt_from_string( GetBiblioData($biblionumber)->{timestamp} ); |
282 |
my $my_content_letter = qq|Dear Jane Smith, |
285 |
my $my_content_letter = qq|Dear Jane Smith, |
283 |
According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible. |
286 |
According to our current records, you have items that are overdue.Your library does not charge late fines, but please return or renew them at the branch below as soon as possible. |
284 |
|
287 |
|
Lines 293-299
The following item(s) is/are currently $substitute->{status}:
Link Here
|
293 |
|
296 |
|
294 |
Thank-you for your prompt attention to this matter. |
297 |
Thank-you for your prompt attention to this matter. |
295 |
Don't forget your date of birth: | . output_pref({ dt => $date, dateonly => 1 }) . q|. |
298 |
Don't forget your date of birth: | . output_pref({ dt => $date, dateonly => 1 }) . q|. |
296 |
Look at this wonderful biblio timestamp: | . output_pref({ dt => $date }) . ".\n"; |
299 |
Look at this wonderful biblio timestamp: | . output_pref({ dt => $biblio_timestamp }) . ".\n"; |
297 |
|
300 |
|
298 |
is( $prepared_letter->{title}, $my_title_letter, 'GetPreparedLetter returns the title correctly' ); |
301 |
is( $prepared_letter->{title}, $my_title_letter, 'GetPreparedLetter returns the title correctly' ); |
299 |
is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' ); |
302 |
is( $prepared_letter->{content}, $my_content_letter, 'GetPreparedLetter returns the content correctly' ); |
Lines 445-489
warning_like {
Link Here
|
445 |
is($err->{'error'}, 'no_letter', "No TESTACQORDER letter was defined."); |
448 |
is($err->{'error'}, 'no_letter', "No TESTACQORDER letter was defined."); |
446 |
} |
449 |
} |
447 |
|
450 |
|
448 |
subtest 'GetPreparedLetter' => sub { |
|
|
449 |
plan tests => 4; |
450 |
|
451 |
Koha::Notice::Template->new( |
452 |
{ |
453 |
module => 'test', |
454 |
code => 'test', |
455 |
branchcode => '', |
456 |
message_transport_type => 'email' |
457 |
} |
458 |
)->store; |
459 |
my $letter; |
460 |
warning_like { |
461 |
$letter = C4::Letters::GetPreparedLetter( |
462 |
module => 'test', |
463 |
letter_code => 'test', |
464 |
); |
465 |
} |
466 |
qr{^ERROR: nothing to substitute}, |
467 |
'GetPreparedLetter should warn if tables, substiture and repeat are not set'; |
468 |
is( $letter, undef, |
469 |
'No letter should be returned by GetPreparedLetter if something went wrong' |
470 |
); |
471 |
|
472 |
warning_like { |
473 |
$letter = C4::Letters::GetPreparedLetter( |
474 |
module => 'test', |
475 |
letter_code => 'test', |
476 |
substitute => {} |
477 |
); |
478 |
} |
479 |
qr{^ERROR: nothing to substitute}, |
480 |
'GetPreparedLetter should warn if tables, substiture and repeat are not set, even if the key is passed'; |
481 |
is( $letter, undef, |
482 |
'No letter should be returned by GetPreparedLetter if something went wrong' |
483 |
); |
484 |
|
485 |
}; |
486 |
|
487 |
{ |
451 |
{ |
488 |
warning_is { |
452 |
warning_is { |
489 |
$err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) } |
453 |
$err = SendAlerts( 'claimacquisition', [ $ordernumber ], 'TESTACQCLAIM' ) } |
Lines 534-542
is($mail{'To'}, 'john.smith@test.de', "mailto correct in sent serial notificatio
Link Here
|
534 |
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); |
498 |
is($mail{'Message'}, 'Silence in the library,'.$subscriptionid.',No. 0', 'Serial notification text constructed successfully'); |
535 |
} |
499 |
} |
536 |
|
500 |
|
|
|
501 |
subtest 'GetPreparedLetter' => sub { |
502 |
plan tests => 4; |
503 |
|
504 |
Koha::Notice::Template->new( |
505 |
{ |
506 |
module => 'test', |
507 |
code => 'test', |
508 |
branchcode => '', |
509 |
message_transport_type => 'email' |
510 |
} |
511 |
)->store; |
512 |
my $letter; |
513 |
warning_like { |
514 |
$letter = C4::Letters::GetPreparedLetter( |
515 |
module => 'test', |
516 |
letter_code => 'test', |
517 |
); |
518 |
} |
519 |
qr{^ERROR: nothing to substitute}, |
520 |
'GetPreparedLetter should warn if tables, substiture and repeat are not set'; |
521 |
is( $letter, undef, |
522 |
'No letter should be returned by GetPreparedLetter if something went wrong' |
523 |
); |
524 |
|
525 |
warning_like { |
526 |
$letter = C4::Letters::GetPreparedLetter( |
527 |
module => 'test', |
528 |
letter_code => 'test', |
529 |
substitute => {} |
530 |
); |
531 |
} |
532 |
qr{^ERROR: nothing to substitute}, |
533 |
'GetPreparedLetter should warn if tables, substiture and repeat are not set, even if the key is passed'; |
534 |
is( $letter, undef, |
535 |
'No letter should be returned by GetPreparedLetter if something went wrong' |
536 |
); |
537 |
|
538 |
}; |
539 |
|
540 |
|
537 |
|
541 |
|
538 |
subtest 'TranslateNotices' => sub { |
542 |
subtest 'TranslateNotices' => sub { |
539 |
plan tests => 3; |
543 |
plan tests => 4; |
|
|
544 |
|
545 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '1' ); |
546 |
|
540 |
$dbh->do( |
547 |
$dbh->do( |
541 |
q| |
548 |
q| |
542 |
INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES |
549 |
INSERT INTO letter (module, code, branchcode, name, title, content, message_transport_type, lang) VALUES |
Lines 546-551
subtest 'TranslateNotices' => sub {
Link Here
|
546 |
my $substitute = {}; |
553 |
my $substitute = {}; |
547 |
my $letter = C4::Letters::GetPreparedLetter( |
554 |
my $letter = C4::Letters::GetPreparedLetter( |
548 |
module => 'test', |
555 |
module => 'test', |
|
|
556 |
tables => $tables, |
549 |
letter_code => 'code', |
557 |
letter_code => 'code', |
550 |
message_transport_type => 'email', |
558 |
message_transport_type => 'email', |
551 |
substitute => $substitute, |
559 |
substitute => $substitute, |
Lines 558-563
subtest 'TranslateNotices' => sub {
Link Here
|
558 |
|
566 |
|
559 |
$letter = C4::Letters::GetPreparedLetter( |
567 |
$letter = C4::Letters::GetPreparedLetter( |
560 |
module => 'test', |
568 |
module => 'test', |
|
|
569 |
tables => $tables, |
561 |
letter_code => 'code', |
570 |
letter_code => 'code', |
562 |
message_transport_type => 'email', |
571 |
message_transport_type => 'email', |
563 |
substitute => $substitute, |
572 |
substitute => $substitute, |
Lines 568-573
subtest 'TranslateNotices' => sub {
Link Here
|
568 |
|
577 |
|
569 |
$letter = C4::Letters::GetPreparedLetter( |
578 |
$letter = C4::Letters::GetPreparedLetter( |
570 |
module => 'test', |
579 |
module => 'test', |
|
|
580 |
tables => $tables, |
571 |
letter_code => 'code', |
581 |
letter_code => 'code', |
572 |
message_transport_type => 'email', |
582 |
message_transport_type => 'email', |
573 |
substitute => $substitute, |
583 |
substitute => $substitute, |
Lines 578-586
subtest 'TranslateNotices' => sub {
Link Here
|
578 |
'a test', |
588 |
'a test', |
579 |
'GetPreparedLetter should return the default notice if the one required does not exist' |
589 |
'GetPreparedLetter should return the default notice if the one required does not exist' |
580 |
); |
590 |
); |
|
|
591 |
|
592 |
t::lib::Mocks::mock_preference( 'TranslateNotices', '' ); |
593 |
|
594 |
$letter = C4::Letters::GetPreparedLetter( |
595 |
module => 'test', |
596 |
tables => $tables, |
597 |
letter_code => 'code', |
598 |
message_transport_type => 'email', |
599 |
substitute => $substitute, |
600 |
lang => 'es-ES', |
601 |
); |
602 |
is( $letter->{title}, 'a test', |
603 |
'GetPreparedLetter should return the default notice if pref disabled but additional language exists' ); |
604 |
|
581 |
}; |
605 |
}; |
582 |
|
606 |
|
583 |
subtest 'SendQueuedMessages' => sub { |
607 |
subtest 'SendQueuedMessages' => sub { |
|
|
608 |
|
584 |
plan tests => 1; |
609 |
plan tests => 1; |
585 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
610 |
t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); |
586 |
my $patron = Koha::Patrons->find($borrowernumber); |
611 |
my $patron = Koha::Patrons->find($borrowernumber); |
Lines 591-594
subtest 'SendQueuedMessages' => sub {
Link Here
|
591 |
); |
616 |
); |
592 |
eval { C4::Letters::SendQueuedMessages(); }; |
617 |
eval { C4::Letters::SendQueuedMessages(); }; |
593 |
is( $@, '', 'SendQueuedMessages should not explode if the patron does not have a sms provider set' ); |
618 |
is( $@, '', 'SendQueuedMessages should not explode if the patron does not have a sms provider set' ); |
|
|
619 |
|
594 |
}; |
620 |
}; |
595 |
- |
|
|