From 005e5ddd349a57796c8a9ad9707e23e726bb4c58 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Tue, 22 Oct 2024 11:39:09 +0000 Subject: [PATCH] Bug 38235: Unit tests BTW, tiny adjustments to existing tests to work with modified C4::Suggestions::ModSuggestion. --- t/db_dependent/Suggestions.t | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 97a0d80ab9..c25a97da7d 100755 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -18,7 +18,7 @@ use Modern::Perl; use DateTime::Duration; -use Test::More tests => 92; +use Test::More tests => 94; use Test::Warn; use t::lib::Mocks; @@ -64,6 +64,7 @@ $dbh->do(q|DELETE FROM borrowers|); $dbh->do(q|DELETE FROM letter|); $dbh->do(q|DELETE FROM message_queue|); $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'CHECKED', 'my content')|); +$dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'ORDERED', 'my content')|); $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'NEW_SUGGESTION', 'Content for new suggestion')|); # Add CPL if missing. @@ -242,7 +243,11 @@ is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEm #Check the message_transport_type when the 'FallbackToSMSIfNoEmail' syspref is enabled and the borrower has a smsalertnumber and no email t::lib::Mocks::mock_preference( 'FallbackToSMSIfNoEmail', 1 ); -ModSuggestion($mod_suggestion3); +my $mod_suggestion3a = { + STATUS => 'ORDERED', + suggestionid => $my_suggestionid, +}; +ModSuggestion($mod_suggestion3a); $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); @@ -264,6 +269,20 @@ $messages = C4::Letters::GetQueuedMessages({ }); is ($messages->[0]->{message_transport_type}, 'email', 'When FallbackToSMSIfNoEmail syspref is enabled the suggestion message_transport_type is email if the borrower has an email'); +# changing STATUS from ORDERED to CHECKED should generate a message +my $mod_suggestion5 = { + STATUS => 'CHECKED', + suggestionid => $my_suggestionid, +}; +$status = ModSuggestion($mod_suggestion5); +$messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); +is( @$messages, 3, 'ModSuggestions does send a message if the status has been changed' ); + +# modifying suggestion without changing STATUS should not generate a message +$status = ModSuggestion($mod_suggestion5); +$messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber } ); +is( @$messages, 3, 'ModSuggestions does send a message if the status has been changed' ); + { # Hiding the expected warning displayed by DBI # DBD::mysql::st execute failed: Incorrect date value: 'invalid date!' for column 'manageddate' -- 2.39.5