From 512d0bfbd417e9e2d7f2e0e46882979138091e96 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 25 Jun 2020 10:38:16 +0000 Subject: [PATCH] Bug 25875: Unit test Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit a804d4be437a5df3641f854a506642afe3501046) Signed-off-by: Lucas Gass (cherry picked from commit 7467f10ceb52696f263746d5495532e2b63b8f5b) Signed-off-by: Aleisha Amohia --- t/db_dependent/Utils/Datatables_Members.t | 35 ++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t index 8fbbfb80a3..291012b6ae 100644 --- a/t/db_dependent/Utils/Datatables_Members.t +++ b/t/db_dependent/Utils/Datatables_Members.t @@ -467,7 +467,7 @@ subtest 'ExtendedPatronAttributes' => sub { }; subtest 'Search with permissions' => sub { - plan tests => 2; + plan tests => 4; my $superlibrarian = $builder->build_object( { @@ -515,6 +515,39 @@ subtest 'Search with permissions' => sub { ], 'We got the 3 patrons we expected' ); + + C4::Context->dbh->do( + q|INSERT INTO user_permissions(borrowernumber, module_bit, code) VALUES(?,?,?)|, + undef, + $librarian_with_subpermission->borrowernumber, + 13, + 'moderate_comments' + ); + $search_results = C4::Utils::DataTables::Members::search( + { + searchmember => "", + searchfieldstype => 'standard', + searchtype => 'contain', + branchcode => $branchcode, + has_permission => { + permission => 'suggestions', + subpermission => 'suggestions_manage' + }, + dt_params => { iDisplayLength => 3, iDisplayStart => 0 }, + } + ); + is( $search_results->{iTotalDisplayRecords}, + 3, "We find 3 patrons with suggestions_manage permission" ); + is_deeply( + [ sort map { $_->{borrowernumber} } @{ $search_results->{patrons} } ], + [ + $superlibrarian->borrowernumber, + $librarian_with_full_permission->borrowernumber, + $librarian_with_subpermission->borrowernumber + ], + 'We got the 3 patrons we expected' + ); + }; subtest 'return values' => sub { -- 2.39.5