Bug 11491: add option to supply field names in reports web service output
[koha.git] / t / db_dependent / Auth_SearchHistorySession.t
blob1e0a0ea2dd0152fa470f81d18527a57254d5105c
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More tests => 4;
8 use_ok('C4::Auth', qw/ParseSearchHistorySession SetSearchHistorySession get_session/);
10 my $expected_recent_searches = [
12 'time' => 1374978877,
13 'query_cgi' => 'idx=&q=history&branch_group_limit=',
14 'total' => 2,
15 'query_desc' => 'kw,wrdl: history, '
19 # Create new session and put its id into CGISESSID cookie
20 my $session = get_session("");
21 $session->flush;
22 my $input = new CookieSimulator({CGISESSID => $session->id});
24 my @recent_searches = ParseSearchHistorySession($input);
25 is_deeply(\@recent_searches, [], 'at start, there is no recent searches');
27 SetSearchHistorySession($input, $expected_recent_searches);
28 @recent_searches = ParseSearchHistorySession($input);
29 is_deeply(\@recent_searches, $expected_recent_searches, 'recent searches set and retrieved successfully');
31 SetSearchHistorySession($input, []);
32 @recent_searches = ParseSearchHistorySession($input);
33 is_deeply(\@recent_searches, [], 'recent searches emptied successfully');
35 # Delete session
36 $session->delete;
37 $session->flush;
39 package CookieSimulator;
41 sub new {
42 my ($class, $hashref) = @_;
43 my $val = $hashref;
44 return bless $val, $class;
47 sub cookie {
48 my ($self, $name) = @_;
49 return $self->{$name};