Browse Source

SimpleSearch test cases - make more robust

Test cases in KohaTest/Search/SimpleSearch.pm assumed
that they were the first to call add_biblios(); as
this is not necessarily true when the entire test
suite is run, test now counts how many 'Finn Test'
bibs already exist.

No documentation changes.

Signed-off-by: Andrew Moore <andrew.moore@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Galen Charlton 16 years ago
committed by Joshua Ferraro
parent
commit
f80b5569d7
  1. 12
      t/lib/KohaTest/Search/SimpleSearch.pm

12
t/lib/KohaTest/Search/SimpleSearch.pm

@ -20,10 +20,14 @@ These get run once, before the main test methods in this module
sub insert_test_data : Test( startup => 71 ) {
my $self = shift;
# get original 'Finn Test' count
my $query = 'Finn Test';
my ( $error, $results ) = SimpleSearch( $query );
$self->{'orig_finn_test_hits'} = scalar(@$results);
# I'm going to add a bunch of biblios so that I can search for them.
$self->add_biblios( count => 10,
add_items => 1 );
}
@ -100,7 +104,8 @@ sub limits : Test( 8 ) {
{
my ( $error, $results ) = SimpleSearch( $query );
ok( ! defined $error, 'no error found during search' );
is( scalar @$results, 10, 'found all 10 results.' )
my $expected_hits = 10 + $self->{'orig_finn_test_hits'};
is( scalar @$results, $expected_hits, "found all $expected_hits results." )
or diag( Data::Dumper->Dump( [ $results ], [ 'results' ] ) );
}
@ -108,7 +113,8 @@ sub limits : Test( 8 ) {
{
my ( $error, $results ) = SimpleSearch( $query, $offset );
ok( ! defined $error, 'no error found during search' );
is( scalar @$results, 6, 'found 6 results.' )
my $expected_hits = 6 + $self->{'orig_finn_test_hits'};
is( scalar @$results, $expected_hits, "found $expected_hits results." )
or diag( Data::Dumper->Dump( [ $results ], [ 'results' ] ) );
}

Loading…
Cancel
Save