|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use DateTime::Duration; |
20 |
use DateTime::Duration; |
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 52; |
22 |
use Test::More tests => 51; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
| 25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
Lines 38-44
use Koha::Suggestions;
Link Here
|
| 38 |
BEGIN { |
38 |
BEGIN { |
| 39 |
use_ok( |
39 |
use_ok( |
| 40 |
'C4::Suggestions', |
40 |
'C4::Suggestions', |
| 41 |
qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) |
41 |
qw( ModSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions ) |
| 42 |
); |
42 |
); |
| 43 |
} |
43 |
} |
| 44 |
|
44 |
|
|
Lines 429-472
subtest 'GetUnprocessedSuggestions' => sub {
Link Here
|
| 429 |
); |
429 |
); |
| 430 |
}; |
430 |
}; |
| 431 |
|
431 |
|
| 432 |
subtest 'DelSuggestionsOlderThan' => sub { |
|
|
| 433 |
plan tests => 6; |
| 434 |
|
| 435 |
Koha::Suggestions->delete; |
| 436 |
|
| 437 |
# Add four suggestions; note that STATUS needs uppercase (FIXME) |
| 438 |
my $d1 = output_pref( { dt => dt_from_string->add( days => -2 ), dateformat => 'sql' } ); |
| 439 |
my $d2 = output_pref( { dt => dt_from_string->add( days => -4 ), dateformat => 'sql' } ); |
| 440 |
my $sugg01 = |
| 441 |
$builder->build( { source => 'Suggestion', value => { manageddate => $d1, date => $d2, STATUS => 'ASKED' } } ); |
| 442 |
my $sugg02 = $builder->build( |
| 443 |
{ source => 'Suggestion', value => { manageddate => $d1, date => $d2, STATUS => 'CHECKED' } } ); |
| 444 |
my $sugg03 = |
| 445 |
$builder->build( { source => 'Suggestion', value => { manageddate => $d2, date => $d2, STATUS => 'ASKED' } } ); |
| 446 |
my $sugg04 = $builder->build( |
| 447 |
{ source => 'Suggestion', value => { manageddate => $d2, date => $d2, STATUS => 'ACCEPTED' } } ); |
| 448 |
|
| 449 |
# Test no parameter: should do nothing |
| 450 |
C4::Suggestions::DelSuggestionsOlderThan(); |
| 451 |
is( Koha::Suggestions->count, 4, 'No suggestions deleted' ); |
| 452 |
|
| 453 |
# Test zero: should do nothing too |
| 454 |
C4::Suggestions::DelSuggestionsOlderThan(0); |
| 455 |
is( Koha::Suggestions->count, 4, 'No suggestions deleted again' ); |
| 456 |
|
| 457 |
# Test negative value |
| 458 |
C4::Suggestions::DelSuggestionsOlderThan(-1); |
| 459 |
is( Koha::Suggestions->count, 4, 'No suggestions deleted for -1' ); |
| 460 |
|
| 461 |
# Test positive values |
| 462 |
C4::Suggestions::DelSuggestionsOlderThan(5); |
| 463 |
is( Koha::Suggestions->count, 4, 'No suggestions>5d deleted' ); |
| 464 |
C4::Suggestions::DelSuggestionsOlderThan(3); |
| 465 |
is( Koha::Suggestions->count, 3, '1 suggestions>3d deleted' ); |
| 466 |
C4::Suggestions::DelSuggestionsOlderThan(1); |
| 467 |
is( Koha::Suggestions->count, 2, '1 suggestions>1d deleted' ); |
| 468 |
}; |
| 469 |
|
| 470 |
subtest 'EmailPurchaseSuggestions' => sub { |
432 |
subtest 'EmailPurchaseSuggestions' => sub { |
| 471 |
plan tests => 11; |
433 |
plan tests => 11; |
| 472 |
|
434 |
|
| 473 |
- |
|
|