6 use Test
::More tests
=> 4;
8 use_ok
('C4::Auth', qw
/ParseSearchHistorySession SetSearchHistorySession get_session/);
10 my $expected_recent_searches = [
13 'query_cgi' => 'idx=&q=history&branch_group_limit=',
15 'query_desc' => 'kw,wrdl: history, '
19 # Create new session and put its id into CGISESSID cookie
20 my $session = get_session
("");
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');
39 package CookieSimulator
;
42 my ($class, $hashref) = @_;
44 return bless $val, $class;
48 my ($self, $name) = @_;
49 return $self->{$name};