Bug 24964: [19.11.x] Add tests
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
(cherry picked from commit b3d97ce029)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
bfd709df69
commit
da20e30b9c
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 50;
|
||||
use Test::More tests => 51;
|
||||
|
||||
use C4::Context;
|
||||
use C4::Members;
|
||||
|
|
@ -57,7 +57,8 @@ my $john_doe = $builder->build({
|
|||
surname => 'Doe',
|
||||
branchcode => $branchcode,
|
||||
dateofbirth => '1983-03-01',
|
||||
userid => 'john.doe'
|
||||
userid => 'john.doe',
|
||||
flags => 0,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -69,7 +70,8 @@ my $john_smith = $builder->build({
|
|||
surname => 'Smith',
|
||||
branchcode => $branchcode,
|
||||
dateofbirth => '1982-02-01',
|
||||
userid => 'john.smith'
|
||||
userid => 'john.smith',
|
||||
flags => 0,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -81,7 +83,8 @@ my $jane_doe = $builder->build({
|
|||
surname => 'Doe',
|
||||
branchcode => $branchcode,
|
||||
dateofbirth => '1983-03-01',
|
||||
userid => 'jane.doe'
|
||||
userid => 'jane.doe',
|
||||
flags => 0,
|
||||
},
|
||||
});
|
||||
my $jeanpaul_dupont = $builder->build({
|
||||
|
|
@ -92,7 +95,8 @@ my $jeanpaul_dupont = $builder->build({
|
|||
surname => 'Dupont',
|
||||
branchcode => $branchcode,
|
||||
dateofbirth => '1982-02-01',
|
||||
userid => 'jeanpaul.dupont'
|
||||
userid => 'jeanpaul.dupont',
|
||||
flags => 0,
|
||||
},
|
||||
});
|
||||
my $dupont_brown = $builder->build({
|
||||
|
|
@ -103,7 +107,8 @@ my $dupont_brown = $builder->build({
|
|||
surname => 'Brown',
|
||||
branchcode => $branchcode,
|
||||
dateofbirth => '1979-01-01',
|
||||
userid => 'dupont.brown'
|
||||
userid => 'dupont.brown',
|
||||
flags => 0,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -461,5 +466,56 @@ subtest 'ExtendedPatronAttributes' => sub {
|
|||
"'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)");
|
||||
};
|
||||
|
||||
subtest 'Search with permissions' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
my $superlibrarian = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => { branchcode => $branchcode, flags => 1 }
|
||||
}
|
||||
);
|
||||
my $librarian_with_full_permission = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => { branchcode => $branchcode, flags => 4100 }
|
||||
}
|
||||
); # 4100 = 4096 (2^12 suggestions) + 4 (2^2 catalogue)
|
||||
my $librarian_with_subpermission = $builder->build_object(
|
||||
{ class => 'Koha::Patrons', value => { branchcode => $branchcode } } );
|
||||
C4::Context->dbh->do(
|
||||
q|INSERT INTO user_permissions(borrowernumber, module_bit, code) VALUES(?,?,?)|,
|
||||
undef,
|
||||
$librarian_with_subpermission->borrowernumber,
|
||||
12,
|
||||
'suggestions_manage'
|
||||
);
|
||||
|
||||
my $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(
|
||||
[ map { $_->{borrowernumber} } @{ $search_results->{patrons} } ],
|
||||
[
|
||||
$superlibrarian->borrowernumber,
|
||||
$librarian_with_full_permission->borrowernumber,
|
||||
$librarian_with_subpermission->borrowernumber
|
||||
],
|
||||
'We got the 3 patrons we expected'
|
||||
);
|
||||
};
|
||||
|
||||
# End
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue