Bugzilla – Attachment 20069 Details for
Bug 10361
Add Option to cleanup_database.pl to purge search_history entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10361: (follow-up) add tests for search history functions
Bug-10361-follow-up-add-tests-for-search-history-f.patch (text/plain), 3.42 KB, created by
Galen Charlton
on 2013-08-02 16:27:16 UTC
(
hide
)
Description:
Bug 10361: (follow-up) add tests for search history functions
Filename:
MIME Type:
Creator:
Galen Charlton
Created:
2013-08-02 16:27:16 UTC
Size:
3.42 KB
patch
obsolete
>From 6613f2f7f39ccbd65d9afc0be170d07a7dd7a7f6 Mon Sep 17 00:00:00 2001 >From: Galen Charlton <gmc@esilibrary.com> >Date: Fri, 2 Aug 2013 16:22:41 +0000 >Subject: [PATCH] Bug 10361: (follow-up) add tests for search history > functions > >This adds tests for the new PurgeSearchHistory function and >AddSearchHistory. GetSearchHistory is not tested due to its >current broken state (see bug 10667). > >To test: > >[1] Run prove -v t/db_dependent/Search_SearchHistory.t >[2] Verify that all tests pass. > >Signed-off-by: Galen Charlton <gmc@esilibrary.com> >--- > t/db_dependent/Search_SearchHistory.t | 71 +++++++++++++++++++++++++++++++++ > 1 file changed, 71 insertions(+) > create mode 100644 t/db_dependent/Search_SearchHistory.t > >diff --git a/t/db_dependent/Search_SearchHistory.t b/t/db_dependent/Search_SearchHistory.t >new file mode 100644 >index 0000000..fa695cc >--- /dev/null >+++ b/t/db_dependent/Search_SearchHistory.t >@@ -0,0 +1,71 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2013 Equinox Software, Inc. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 6; >+ >+use C4::Context; >+use_ok('C4::Search', qw/AddSearchHistory PurgeSearchHistory/); # GetSearchHistory is not exported >+ >+# Start transaction >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# start with a clean slate >+$dbh->do('DELETE FROM search_history'); >+is(_get_history_count(), 0, 'starting off with nothing in search_history'); >+ >+# Add some history rows. Note that we're ignoring the return value; >+# since the search_history table doesn't have an auto_increment >+# column, it appears that the value of $dbh->last_insert_id() is >+# useless for determining if the insert failed. >+AddSearchHistory(12345, 'session_1', 'query_desc_1', 'query_cgi_1', 5); >+AddSearchHistory(12345, 'session_1', 'query_desc_2', 'query_cgi_2', 6); >+AddSearchHistory(12345, 'session_1', 'query_desc_3', 'query_cgi_3', 7); >+AddSearchHistory(56789, 'session_2', 'query_desc_4', 'query_cgi_4', 8); >+is(_get_history_count(), 4, 'successfully added four search_history rows'); >+ >+# We're not testing GetSearchHistory at present because it is broken... >+# see bug 10677 >+ >+# munge some dates >+my $sth = $dbh->prepare(' >+ UPDATE search_history >+ SET time = DATE_SUB(time, INTERVAL ? DAY) >+ WHERE query_desc = ? >+'); >+$sth->execute(46, 'query_desc_1'); >+$sth->execute(31, 'query_desc_2'); >+ >+PurgeSearchHistory(45); >+is(_get_history_count(), 3, 'purged history older than 45 days'); >+PurgeSearchHistory(30); >+is(_get_history_count(), 2, 'purged history older than 30 days'); >+PurgeSearchHistory(-1); >+is(_get_history_count(), 0, 'purged all history'); >+ >+sub _get_history_count { >+ my $count_sth = $dbh->prepare('SELECT COUNT(*) FROM search_history'); >+ $count_sth->execute(); >+ my $count = $count_sth->fetchall_arrayref(); >+ return $count->[0]->[0]; >+} >+ >+$dbh->rollback; >-- >1.7.10.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 10361
:
18424
|
18838
|
18839
|
20067
|
20068
|
20069
|
20258
|
20740
|
20741