Lines 20-30
use Modern::Perl;
Link Here
|
20 |
use C4::Context; |
20 |
use C4::Context; |
21 |
use C4::Members; |
21 |
use C4::Members; |
22 |
use C4::Letters; |
22 |
use C4::Letters; |
23 |
use C4::Budgets; |
23 |
use C4::Budgets qw( AddBudgetPeriod AddBudget ); |
24 |
|
24 |
|
25 |
use Koha::DateUtils qw( dt_from_string ); |
25 |
use Koha::DateUtils qw( dt_from_string ); |
26 |
|
26 |
|
27 |
use Test::More tests => 104; |
27 |
use DateTime::Duration; |
|
|
28 |
use Test::More tests => 105; |
28 |
use Test::Warn; |
29 |
use Test::Warn; |
29 |
|
30 |
|
30 |
BEGIN { |
31 |
BEGIN { |
Lines 328-330
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB
Link Here
|
328 |
ModSuggestion( $my_suggestion ); |
329 |
ModSuggestion( $my_suggestion ); |
329 |
$suggestion = GetSuggestion($my_suggestionid_test_budgetid); |
330 |
$suggestion = GetSuggestion($my_suggestionid_test_budgetid); |
330 |
is( $suggestion->{budgetid}, undef, 'NewSuggestion Should set budgetid to NULL if equals an empty string' ); |
331 |
is( $suggestion->{budgetid}, undef, 'NewSuggestion Should set budgetid to NULL if equals an empty string' ); |
331 |
- |
332 |
|
|
|
333 |
subtest 'GetUnprocessedSuggestions' => sub { |
334 |
plan tests => 9; |
335 |
$dbh->do(q|DELETE FROM suggestions|); |
336 |
my $my_suggestionid = NewSuggestion($my_suggestion); |
337 |
my $unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; |
338 |
is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should return 0 if a suggestion has been processed but not linked to a fund' ); |
339 |
my $status = ModSuggestion($mod_suggestion1); |
340 |
my $suggestion = GetSuggestion($my_suggestionid); |
341 |
is( $suggestion->{budgetid}, undef, 'ModSuggestion should set budgetid to NULL if not given' ); |
342 |
ModSuggestion( { suggestionid => $my_suggestionid, budgetid => $budget_id } ); |
343 |
$suggestion = GetSuggestion($my_suggestionid); |
344 |
is( $suggestion->{budgetid}, $budget_id, 'ModSuggestion should modify budgetid if given' ); |
345 |
|
346 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; |
347 |
is( scalar(@$unprocessed_suggestions), 1, 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' ); |
348 |
|
349 |
ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'REJECTED' } ); |
350 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; |
351 |
is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should return the suggestion if the suggestion is linked to a fund and has not been processed yet' ); |
352 |
|
353 |
ModSuggestion( { suggestionid => $my_suggestionid, STATUS => 'ASKED', suggesteddate => dt_from_string->add_duration( DateTime::Duration->new( days => -4 ) ) } ); |
354 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions; |
355 |
is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should use 0 as default value for days' ); |
356 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(4); |
357 |
is( scalar(@$unprocessed_suggestions), 1, 'GetUnprocessedSuggestions should return the suggestion suggested 4 days ago' ); |
358 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(3); |
359 |
is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should not return the suggestion, it has not been suggested 3 days ago' ); |
360 |
$unprocessed_suggestions = C4::Suggestions::GetUnprocessedSuggestions(5); |
361 |
is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should not return the suggestion, it has not been suggested 5 days ago' ); |
362 |
}; |