From 638a6343f653fdf0a04504ada952d01978d4733a Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 25 Nov 2015 14:02:05 +0100 Subject: [PATCH] Bug 15252 - Add tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Tested 4 patches together, works as expected. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit f0da781368a187337236d64ee94d9c8cc65f90f7) Signed-off-by: Julian Maurice --- t/db_dependent/Utils/Datatables_Members.t | 60 ++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t index 9f8cda8d54..855d129fa0 100644 --- a/t/db_dependent/Utils/Datatables_Members.t +++ b/t/db_dependent/Utils/Datatables_Members.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 15; +use Test::More tests => 19; use C4::Context; use C4::Branch; @@ -87,12 +87,25 @@ my %jane_doe = ( userid => 'jane.doe' ); +my %jeanpaul_dupont = ( + cardnumber => '456789', + firstname => 'Jean Paul', + surname => 'Dupont', + categorycode => $categorycode, + branchcode => $branchcode, + dateofbirth => '', + dateexpiry => '9999-12-31', + userid => 'jeanpaul.dupont' +); + $john_doe{borrowernumber} = AddMember( %john_doe ); warn "Error adding John Doe, check your tests" unless $john_doe{borrowernumber}; $john_smith{borrowernumber} = AddMember( %john_smith ); warn "Error adding John Smith, check your tests" unless $john_smith{borrowernumber}; $jane_doe{borrowernumber} = AddMember( %jane_doe ); warn "Error adding Jane Doe, check your tests" unless $jane_doe{borrowernumber}; +$jeanpaul_dupont{borrowernumber} = AddMember( %jeanpaul_dupont ); +warn "Error adding Jean Paul Dupont, check your tests" unless $jeanpaul_dupont{borrowernumber}; # Set common datatables params my %dt_params = ( @@ -228,6 +241,51 @@ $search_results = C4::Utils::DataTables::Members::search({ }); is( $search_results->{ iTotalDisplayRecords}, 0, "There are still 2 common users, but the patron attribute is not searchable " ); +$search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Jean Paul", + searchfieldstype => 'standard', + searchtype => 'start_with', + branchcode => $branchcode, + dt_params => \%dt_params +}); + +is( $search_results->{ iTotalDisplayRecords }, 1, + "Jean Paul Dupont is found using start with and two terms search 'Jean Paul' (Bug 15252)"); + +$search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Jean Pau", + searchfieldstype => 'standard', + searchtype => 'start_with', + branchcode => $branchcode, + dt_params => \%dt_params +}); + +is( $search_results->{ iTotalDisplayRecords }, 1, + "Jean Paul Dupont is found using start with and two terms search 'Jean Pau' (Bug 15252)"); + +$search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Jea Pau", + searchfieldstype => 'standard', + searchtype => 'start_with', + branchcode => $branchcode, + dt_params => \%dt_params +}); + +is( $search_results->{ iTotalDisplayRecords }, 0, + "Jean Paul Dupont is not found using start with and two terms search 'Jea Pau' (Bug 15252)"); + +$search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Jea Pau", + searchfieldstype => 'standard', + searchtype => 'contain', + branchcode => $branchcode, + dt_params => \%dt_params +}); + +is( $search_results->{ iTotalDisplayRecords }, 1, + "Jean Paul Dupont is found using contains and two terms search 'Jea Pau' (Bug 15252)"); + +# End $dbh->rollback; 1; -- 2.39.5