Bugzilla – Attachment 165578 Details for
Bug 36122
NEW_SUGGESTION is sent for every modification to the suggestion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36122: add unit test
Bug-36122-add-unit-test.patch (text/plain), 3.00 KB, created by
Roman Dolny
on 2024-04-25 18:52:17 UTC
(
hide
)
Description:
Bug 36122: add unit test
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2024-04-25 18:52:17 UTC
Size:
3.00 KB
patch
obsolete
>From b42249cda3294ca1539672a83eb655051ee930ba Mon Sep 17 00:00:00 2001 >From: Matthias Le Gac <matthias.le-gac@inlibro.com> >Date: Fri, 8 Mar 2024 16:44:51 -0500 >Subject: [PATCH] Bug 36122: add unit test > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > t/db_dependent/Koha/Suggestions.t | 42 ++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Suggestions.t b/t/db_dependent/Koha/Suggestions.t >index 7c2e443458..467e207a92 100755 >--- a/t/db_dependent/Koha/Suggestions.t >+++ b/t/db_dependent/Koha/Suggestions.t >@@ -23,6 +23,8 @@ use Test::More tests => 11; > use Test::Exception; > > use Koha::Suggestions; >+use Koha::Config::SysPrefs; >+use Koha::Notice::Messages; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string output_pref ); > >@@ -49,7 +51,7 @@ my $new_suggestion_2 = Koha::Suggestion->new( > )->store; > > subtest 'store' => sub { >- plan tests => 5; >+ plan tests => 8; > my $suggestion = Koha::Suggestion->new( > { suggestedby => $patron->{borrowernumber}, > biblionumber => $biblio_1->biblionumber, >@@ -66,6 +68,44 @@ subtest 'store' => sub { > $suggestion = Koha::Suggestions->find( $suggestion->suggestionid ); > is( $suggestion->suggesteddate, $two_days_ago_sql, 'If suggestion id modified, suggesteddate should not be modified' ); > >+ my $syspref = Koha::Config::SysPrefs->find('EmailPurchaseSuggestions'); >+ $syspref->value(0)->store; >+ Koha::Notice::Messages->search->delete; >+ $suggestion->STATUS('ASKED')->store; >+ my $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >+ if ( !defined $last_message ) { >+ $last_message = "No message was sent"; >+ } >+ is( >+ $last_message, 'No message was sent', >+ 'If EmailPurchaseSuggestions is not enabled, a message should not be sent' >+ ); >+ >+ $syspref = Koha::Config::SysPrefs->find('EmailPurchaseSuggestions'); >+ $syspref->value('EmailAddressForSuggestions')->store; >+ Koha::Notice::Messages->search->delete; >+ $suggestion->STATUS('ASKED')->store; >+ $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >+ if ( !defined $last_message ) { >+ fail('No message was sent'); >+ } else { >+ is( >+ $last_message->letter_code, 'NEW_SUGGESTION', >+ 'If EmailPurchaseSuggestions is enabled and the status of suggestion is set to ASKED, a message should be sent' >+ ); >+ } >+ >+ Koha::Notice::Messages->search->delete; >+ $suggestion->STATUS('ACCEPTED')->store; >+ $last_message = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->single; >+ if ( !defined $last_message ) { >+ $last_message = "No message was sent"; >+ } >+ is( >+ $last_message, 'No message was sent', >+ 'If the status of suggestion is not set to ASKED, a message should not be sent' >+ ); >+ > throws_ok { > $suggestion->STATUS('UNKNOWN')->store; > } >-- >2.39.2
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 36122
:
162962
|
162989
|
164481
|
165577
|
165578
|
165579
|
166051
|
166052
|
166053