From f80b5569d796f51965d8580549ac2073f31b868c Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 1 Jul 2008 12:36:28 -0500 Subject: [PATCH] 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 Signed-off-by: Joshua Ferraro --- t/lib/KohaTest/Search/SimpleSearch.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/t/lib/KohaTest/Search/SimpleSearch.pm b/t/lib/KohaTest/Search/SimpleSearch.pm index aaf2fa9289..95324f2441 100644 --- a/t/lib/KohaTest/Search/SimpleSearch.pm +++ b/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' ] ) ); } -- 2.20.1