Bugzilla – Attachment 72108 Details for
Bug 13287
Add a system preference to define the number of days used in purge_suggestions.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13287: (QA follow-up) Extend Suggestions.t for DelSuggestionsOlderThan
Bug-13287-QA-follow-up-Extend-Suggestionst-for-Del.patch (text/plain), 3.79 KB, created by
Marcel de Rooy
on 2018-02-23 10:45:06 UTC
(
hide
)
Description:
Bug 13287: (QA follow-up) Extend Suggestions.t for DelSuggestionsOlderThan
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-02-23 10:45:06 UTC
Size:
3.79 KB
patch
obsolete
>From 39cd3bbfc73cef6d57a31f37f745ca696d159b02 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 23 Feb 2018 10:00:13 +0100 >Subject: [PATCH] Bug 13287: (QA follow-up) Extend Suggestions.t for > DelSuggestionsOlderThan >Content-Type: text/plain; charset=utf-8 > >Adding a days>0 test in the sub with a POD line. >Specific subtest for this sub added in Suggestions.t. > >Test plan: >Run t/db_dependent/Suggestions.t again. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Suggestions.pm | 3 ++- > t/db_dependent/Suggestions.t | 37 +++++++++++++++++++++++++++++++++++-- > 2 files changed, 37 insertions(+), 3 deletions(-) > >diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm >index 1ea2339..70b7b0d 100644 >--- a/C4/Suggestions.pm >+++ b/C4/Suggestions.pm >@@ -588,12 +588,13 @@ sub DelSuggestion { > &DelSuggestionsOlderThan($days) > > Delete all suggestions older than TODAY-$days , that have be accepted or rejected. >+ We do now allow a negative number. If you want to delete all suggestions, just use Koha::Suggestions->delete or so. > > =cut > > sub DelSuggestionsOlderThan { > my ($days) = @_; >- return unless $days; >+ return unless $days && $days > 0; > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare( > q{ >diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t >index 5e9e5ed..6604cd1 100644 >--- 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 => 102; >+use Test::More tests => 103; > use Test::Warn; > > use t::lib::Mocks; >@@ -29,9 +29,10 @@ use C4::Members; > use C4::Letters; > use C4::Budgets qw( AddBudgetPeriod AddBudget ); > use Koha::Database; >-use Koha::DateUtils qw( dt_from_string ); >+use Koha::DateUtils qw( dt_from_string output_pref ); > use Koha::Library; > use Koha::Libraries; >+use Koha::Suggestions; > > BEGIN { > use_ok('C4::Suggestions'); >@@ -382,4 +383,36 @@ subtest 'GetUnprocessedSuggestions' => sub { > is( scalar(@$unprocessed_suggestions), 0, 'GetUnprocessedSuggestions should not return the suggestion, it has not been suggested 5 days ago' ); > }; > >+subtest 'DelSuggestionsOlderThan' => sub { >+ plan tests => 6; >+ >+ Koha::Suggestions->delete; >+ >+ # Add four suggestions; note that STATUS needs uppercase (FIXME) >+ my $d1 = output_pref({ dt => dt_from_string->add(days => -2), dateformat => 'sql' }); >+ my $d2 = output_pref({ dt => dt_from_string->add(days => -4), dateformat => 'sql' }); >+ my $sugg01 = $builder->build({ source => 'Suggestion', value => { date => $d1, STATUS => 'ASKED' }}); >+ my $sugg02 = $builder->build({ source => 'Suggestion', value => { date => $d1, STATUS => 'CHECKED' }}); >+ my $sugg03 = $builder->build({ source => 'Suggestion', value => { date => $d2, STATUS => 'ASKED' }}); >+ my $sugg04 = $builder->build({ source => 'Suggestion', value => { date => $d2, STATUS => 'ACCEPTED' }}); >+ >+ # Test no parameter: should do nothing >+ C4::Suggestions::DelSuggestionsOlderThan(); >+ is( Koha::Suggestions->count, 4, 'No suggestions deleted' ); >+ # Test zero: should do nothing too >+ C4::Suggestions::DelSuggestionsOlderThan(0); >+ is( Koha::Suggestions->count, 4, 'No suggestions deleted again' ); >+ # Test negative value >+ C4::Suggestions::DelSuggestionsOlderThan(-1); >+ is( Koha::Suggestions->count, 4, 'No suggestions deleted for -1' ); >+ >+ # Test positive values >+ C4::Suggestions::DelSuggestionsOlderThan(5); >+ is( Koha::Suggestions->count, 4, 'No suggestions>5d deleted' ); >+ C4::Suggestions::DelSuggestionsOlderThan(3); >+ is( Koha::Suggestions->count, 3, '1 suggestions>3d deleted' ); >+ C4::Suggestions::DelSuggestionsOlderThan(1); >+ is( Koha::Suggestions->count, 2, '1 suggestions>1d deleted' ); >+}; >+ > $schema->storage->txn_rollback; >-- >2.1.4
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 13287
:
33661
|
41219
|
44312
|
48323
|
48324
|
50296
|
50297
|
60569
|
60570
|
68187
|
69142
|
69143
|
72105
|
72106
|
72107
| 72108 |
72109
|
72217