From dde4036df4fba9b8d3652a78c320c42f9e71c660 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 14 Feb 2017 16:19:25 +0100 Subject: [PATCH] Bug 18094: Add tests to highlight the problem MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc Véron Signed-off-by: Nick Clemens Signed-off-by: Brendan A Gallagher (cherry picked from commit f86500351af0a1a4d1593eb2aa689b8ec52bc401) Signed-off-by: Katrin Fischer Conflicts: t/db_dependent/Utils/Datatables_Members.t --- t/db_dependent/Utils/Datatables_Members.t | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t index 4b9ab93b98..02561e4112 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 => 29; +use Test::More tests => 30; use C4::Context; use C4::Members; @@ -296,6 +296,9 @@ C4::Members::Attributes::SetBorrowerAttributes( C4::Members::Attributes::SetBorrowerAttributes( $jane_doe{borrowernumber}, [ { code => $attribute_type->{code}, value => 'the default value for another common user' } ] ); +C4::Members::Attributes::SetBorrowerAttributes( + $john_smith->{borrowernumber}, [ { code => $attribute_type->{code}, value => 'Attribute which not appears even if contains "Dupont"' } ] +); t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); $search_results = C4::Utils::DataTables::Members::search({ @@ -379,6 +382,32 @@ $search_results = C4::Utils::DataTables::Members::search({ is( $search_results->{ iTotalDisplayRecords }, 1, "Sarching by date of birth should handle date formatted in iso"); +subtest 'ExtendedPatronAttributes' => sub { + plan tests => 2; + t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); + $search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Dupont", + searchfieldstype => 'standard', + searchtype => 'contain', + branchcode => $branchcode, + dt_params => \%dt_params + }); + + is( $search_results->{ iTotalDisplayRecords }, 3, + "'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should be displayed if searching in all fields (Bug 18094)"); + + $search_results = C4::Utils::DataTables::Members::search({ + searchmember => "Dupont", + searchfieldstype => 'surname', + searchtype => 'contain', + branchcode => $branchcode, + dt_params => \%dt_params + }); + + is( $search_results->{ iTotalDisplayRecords }, 1, + "'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)"); +}; + # End $dbh->rollback; -- 2.39.5