[Koha-patches] [PATCH 02/55] Fixing Tests on SQLHelper

Henri-Damien LAURENT henridamien.laurent at biblibre.com
Wed Mar 10 22:25:44 CET 2010


one test was failing for want of correct parameters
An other one was not correctly described

test on search with a simple string fails because was done with branchcode and start_with includes NULL branches
Removing branchcode from filtercolumns
---
 t/db_dependent/SQLHelper.t |   34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/t/db_dependent/SQLHelper.t b/t/db_dependent/SQLHelper.t
index c620ebb..80c4478 100755
--- a/t/db_dependent/SQLHelper.t
+++ b/t/db_dependent/SQLHelper.t
@@ -37,40 +37,48 @@ $borrowers=SearchInTable("borrowers",{firstname=>"Jean"});
 #6
 ok(@$borrowers>0, "Search In Table hashref");
 $borrowers=SearchInTable("borrowers",{firstname=>"Jean"},[{firstname=>1},{borrowernumber=>1}],undef, [qw(borrowernumber)]);
+#7
 ok(($$borrowers[0]{borrowernumber} + 0) > ($$borrowers[1]{borrowernumber} + 0), "Search In Table Order");
 $borrowers=SearchInTable("borrowers",{firstname=>"Jean"},[{surname=>0},{firstname=>1}], undef, [qw(firstname surname)]);
+#8
 ok(uc($$borrowers[0]{surname}) lt uc($$borrowers[1]{surname}), "Search In Table Order");
 $borrowers=SearchInTable("borrowers","Jean");
-#7
+#9
 ok(@$borrowers>0, "Search In Table string");
-eval{$borrowers=SearchInTable("borrowers","Jean Valjean")};
-#8
+#10
+#FIXME : When searching on All the fields of the table, seems to return Junk
+eval{$borrowers=SearchInTable("borrowers","Jean Valjean",undef,undef,undef,[qw(firstname surname borrowernumber cardnumber)],"start_with")};
+#eval{$borrowers=SearchInTable("borrowers","Jean Valjean",undef,undef,undef,undef,"start_with")};
+# This would not be much efficient because of "numbers" special treatment : We return stuff if empty or '' as soon as search is NOT exact
+# This behaviour is implemented because of branchcode and numbers can be null
+$debug && warn Dump(@$borrowers);
 ok(scalar(@$borrowers)==1 && !($@), "Search In Table does an implicit AND of all the words in strings");
 $borrowers=SearchInTable("borrowers",["Valjean",{firstname=>"Jean"}]);
-#9
+#11
 ok(@$borrowers>0, "Search In Table arrayref");
 $borrowers=SearchInTable("borrowers",["Valjean",{firstname=>"Jean"}],undef,undef,[qw(borrowernumber)]);
-#10
+#12
 ok(keys %{$$borrowers[0]} ==1, "Search In Table columns out limit");
 $borrowers=SearchInTable("borrowers",["Valjean",{firstname=>"Jean"}],undef,undef,[qw(borrowernumber)],[qw(firstname surname title)]);
-#11
+#13
 ok(@$borrowers>0, "Search In Table columns out limit to borrowernumber AND filter firstname surname title");
 $borrowers=SearchInTable("borrowers",["Valjean",{firstname=>"Jean"}],undef,undef,[qw(borrowernumber)],[qw(firstname title)]);
-#12
+#14
 ok(@$borrowers==0, "Search In Table columns filter firstname title limit Valjean not in other fields than surname ");
 $borrowers=SearchInTable("borrowers",["Val",{firstname=>"Jean"}],undef,undef,[qw(borrowernumber)],[qw(surname)],"start_with");
-#13
+#15
 ok(@$borrowers>0, "Search In Table columns filter surname  Val on a wide search found ");
 $borrowers=SearchInTable("borrowers",["Val",{firstname=>"Jean"}],undef,undef,[qw(borrowernumber)],[qw(surname)],"exact");
-#14
+#16
 ok(@$borrowers==0, "Search In Table columns filter surname  Val in exact search not found ");
 $borrowers=eval{SearchInTable("borrowers",["Val",{member=>"Jean"}],undef,undef,[qw(borrowernumber)],[qw(firstname title)],"exact")};
-#15
-ok(@$borrowers==0 && !($@), "Search In Table fails gracefully when no correct field passed in hash");
-$borrowers=eval{SearchInTable("borrowers",["Jean"],undef,undef,undef,[qw(firstname surname borrowernumber)],"start_with")};
+#17
 ok(@$borrowers==0 && !($@), "Search In Table fails gracefully when no correct field passed in hash");
+#18
+$borrowers=eval{SearchInTable("borrowers",["Jea"],undef,undef,undef,[qw(firstname surname borrowernumber)],"start_with")};
+ok(@$borrowers>0 && !($@), "Search on simple value in firstname");
 
 $status=DeleteInTable("borrowers",{borrowernumber=>$borrid});
-#16
+#19
 ok($status>0 && !($@), "DeleteInTable OK");
 $status=DeleteInTable("borrowers",{borrowernumber=>$borrtmp});
-- 
1.6.3.3




More information about the Koha-patches mailing list