Bug 15629: Koha::Libraries - Remove GetBranchDetail
[koha.git] / t / db_dependent / Suggestions.t
index df8e93b..ddd7f00 100644 (file)
@@ -24,6 +24,7 @@ use C4::Branch;
 use C4::Budgets qw( AddBudgetPeriod AddBudget );
 
 use Koha::DateUtils qw( dt_from_string );
+use Koha::Libraries;
 
 use DateTime::Duration;
 use Test::More tests => 105;
@@ -62,7 +63,7 @@ $dbh->do(q|DELETE FROM message_queue|);
 $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'CHECKED', 'my content')|);
 
 # Add CPL if missing.
-if (not defined GetBranchDetail('CPL')) {
+if (not defined Koha::Libraries->find('CPL')) {
     ModBranch({add => 1, branchcode => 'CPL', branchname => 'Centerville'});
 }
 
@@ -365,7 +366,7 @@ $suggestion = GetSuggestion($my_suggestionid_test_budgetid);
 is( $suggestion->{budgetid}, undef, 'NewSuggestion Should set budgetid to NULL if equals an empty string' );
 
 subtest 'GetUnprocessedSuggestions' => sub {
-    plan tests => 9;
+    plan tests => 11;
     $dbh->do(q|DELETE FROM suggestions|);
     my $my_suggestionid         = NewSuggestion($my_suggestion);
     my $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions;
@@ -380,11 +381,15 @@ subtest 'GetUnprocessedSuggestions' => sub {
     $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions;
     is( scalar(@$unprocessed_suggestions), 1, 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' );
 
-    ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'REJECTED' } );
+    warning_is { ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'REJECTED' } ) }
+                'No suggestions REJECTED letter transported by email',
+                'Warning raised if no REJECTED letter by email';
     $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions;
     is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' );
 
-    ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'ASKED', suggesteddate => dt_from_string->add_duration( DateTime::Duration->new( days => -4 ) ) } );
+    warning_is { ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'ASKED', suggesteddate => dt_from_string->add_duration( DateTime::Duration->new( days => -4 ) ) } ); }
+                'No suggestions ASKED letter transported by email',
+                'Warning raised if no ASKED letter by email';
     $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions;
     is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should use 0 as default value for days' );
     $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(4);