|
Lines 2-9
Link Here
|
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
|
4 |
|
| 5 |
use Test::More tests => 16; |
5 |
use Test::More tests => 18; |
| 6 |
use URI::Escape; |
6 |
use URI::Escape; |
|
|
7 |
use List::Util qw( shuffle ); |
| 7 |
|
8 |
|
| 8 |
use C4::Context; |
9 |
use C4::Context; |
| 9 |
my $dbh = C4::Context->dbh; |
10 |
my $dbh = C4::Context->dbh; |
|
Lines 127-132
$all = C4::Search::History::get({userid => $userid});
Link Here
|
| 127 |
is( scalar(@$all), 9, 'There are still 9 searches after calling delete without userid' ); |
128 |
is( scalar(@$all), 9, 'There are still 9 searches after calling delete without userid' ); |
| 128 |
delete_all( $userid ); |
129 |
delete_all( $userid ); |
| 129 |
|
130 |
|
|
|
131 |
# Delete (with a given id) |
| 132 |
add( $userid, $current_sessionid, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ); |
| 133 |
$all = C4::Search::History::get({ userid => $userid }); |
| 134 |
# Delete 5 searches |
| 135 |
my $ids = [ shuffle map { $_->{id} } @$all ]; |
| 136 |
for my $id ( @$ids[ 0 .. 4 ] ) { |
| 137 |
C4::Search::History::delete({ id => $id }); |
| 138 |
} |
| 139 |
$all = C4::Search::History::get({ userid => $userid }); |
| 140 |
is( scalar(@$all), 4, 'There are 4 searches after calling 5 times delete with id' ); |
| 141 |
delete_all( $userid ); |
| 142 |
|
| 143 |
add( $userid, $current_sessionid, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ); |
| 144 |
$all = C4::Search::History::get({ userid => $userid }); |
| 145 |
# Delete 5 searches |
| 146 |
$ids = [ shuffle map { $_->{id} } @$all ]; |
| 147 |
C4::Search::History::delete({ id => [ @$ids[0..4] ] }); |
| 148 |
$all = C4::Search::History::get({ userid => $userid }); |
| 149 |
is( scalar(@$all), 4, 'There are 4 searches after calling delete with 5 ids' ); |
| 150 |
delete_all( $userid ); |
| 151 |
|
| 130 |
sub add { |
152 |
sub add { |
| 131 |
my ( $userid, $current_session_id, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ) = @_; |
153 |
my ( $userid, $current_session_id, $previous_sessionid, $total, $query_cgi_b, $query_cgi_a ) = @_; |
| 132 |
|
154 |
|
| 133 |
- |
|
|