Bugzilla – Attachment 128390 Details for
Bug 27208
Add a configurable time delay feature to hold notice templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27208: Unit tests
0004-Bug-27208-Unit-tests.patch (text/plain), 3.00 KB, created by
Björn Nylén
on 2021-12-10 10:11:45 UTC
(
hide
)
Description:
Bug 27208: Unit tests
Filename:
MIME Type:
Creator:
Björn Nylén
Created:
2021-12-10 10:11:45 UTC
Size:
3.00 KB
patch
obsolete
>From c734261bb2c8cc5d2b4e79c11d3dea3a560c4d23 Mon Sep 17 00:00:00 2001 >From: root <root@9b7442205204> >Date: Thu, 9 Dec 2021 18:36:12 +0000 >Subject: [PATCH 4/4] Bug 27208: Unit tests > >This commit adds unit test for changes in C4/Letters.pm >--- > t/db_dependent/Letters.t | 33 ++++++++++++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 9a37118503..a0924aff8f 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 83; >+use Test::More tests => 88; > use Test::MockModule; > use Test::Warn; > use Test::Exception; >@@ -147,6 +147,7 @@ is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin > isnt( $messages->[0]->{time_queued}, undef, 'Time queued inserted by default in message_queue table' ); > is( $messages->[0]->{updated_on}, $messages->[0]->{time_queued}, 'Time status changed equals time queued when created in message_queue table' ); > is( $messages->[0]->{failure_code}, '', 'Failure code for successful message correctly empty'); >+is( $messages->[0]->{delay_until}, undef, 'Delay until should be undef if not set'); > > # Setting time_queued to something else than now > my $yesterday = dt_from_string->subtract( days => 1 ); >@@ -171,6 +172,36 @@ is( > isnt($messages->[0]->{updated_on}, $messages->[0]->{time_queued}, 'Time status changed differs from time queued when status changes' ); > is(dt_from_string($messages->[0]->{time_queued}), $yesterday, 'Time queued remaines inmutable' ); > >+# Delayed message >+my $tomorrow = dt_from_string()->add( days => 1 ); >+my $delay_message = { >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'email', >+ to_address => 'to@example', >+ from_address => 'from@example.com', >+ delay_until => $tomorrow, >+}; >+$delay_message->{letter} = { >+ content => 'I am waiting', >+ title => 'Patience is great', >+ metadata => 'metadata', >+ code => 'TEST_MESSAGE', >+ content_type => 'text/plain', >+}; >+ >+my $delayed_message_id = C4::Letters::EnqueueLetter($delay_message); >+ >+my $delay_until = Koha::Notice::Messages->find($delayed_message_id)->delay_until; >+is(dt_from_string($delay_until), $tomorrow, 'Delay_until is properly set'); >+ >+my $delayed_messages_processed = C4::Letters::SendQueuedMessages(); >+is($delayed_messages_processed, 0, 'Message not processed if delay_until is set in the future'); >+ >+Koha::Notice::Messages->find($delayed_message_id)->delay_until($yesterday)->store; >+$delayed_messages_processed = C4::Letters::SendQueuedMessages(); >+is($delayed_messages_processed, 1, 'Message processed if delay_until is set in the past'); >+Koha::Notice::Messages->find($delayed_message_id)->delete; >+ > # ResendMessage > my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); > my $message = C4::Letters::GetMessage( $messages->[0]->{message_id}); >-- >2.20.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27208
:
128387
|
128388
|
128389
|
128390
|
128587
|
128588
|
128589
|
128590
|
128948
|
128949
|
128950
|
128951