|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 50; |
20 |
use Test::More tests => 51; |
| 21 |
|
21 |
|
| 22 |
use C4::Context; |
22 |
use C4::Context; |
| 23 |
use C4::Members; |
23 |
use C4::Members; |
|
Lines 57-63
my $john_doe = $builder->build({
Link Here
|
| 57 |
surname => 'Doe', |
57 |
surname => 'Doe', |
| 58 |
branchcode => $branchcode, |
58 |
branchcode => $branchcode, |
| 59 |
dateofbirth => '1983-03-01', |
59 |
dateofbirth => '1983-03-01', |
| 60 |
userid => 'john.doe' |
60 |
userid => 'john.doe', |
|
|
61 |
flags => 0, |
| 61 |
}, |
62 |
}, |
| 62 |
}); |
63 |
}); |
| 63 |
|
64 |
|
|
Lines 69-75
my $john_smith = $builder->build({
Link Here
|
| 69 |
surname => 'Smith', |
70 |
surname => 'Smith', |
| 70 |
branchcode => $branchcode, |
71 |
branchcode => $branchcode, |
| 71 |
dateofbirth => '1982-02-01', |
72 |
dateofbirth => '1982-02-01', |
| 72 |
userid => 'john.smith' |
73 |
userid => 'john.smith', |
|
|
74 |
flags => 0, |
| 73 |
}, |
75 |
}, |
| 74 |
}); |
76 |
}); |
| 75 |
|
77 |
|
|
Lines 81-87
my $jane_doe = $builder->build({
Link Here
|
| 81 |
surname => 'Doe', |
83 |
surname => 'Doe', |
| 82 |
branchcode => $branchcode, |
84 |
branchcode => $branchcode, |
| 83 |
dateofbirth => '1983-03-01', |
85 |
dateofbirth => '1983-03-01', |
| 84 |
userid => 'jane.doe' |
86 |
userid => 'jane.doe', |
|
|
87 |
flags => 0, |
| 85 |
}, |
88 |
}, |
| 86 |
}); |
89 |
}); |
| 87 |
my $jeanpaul_dupont = $builder->build({ |
90 |
my $jeanpaul_dupont = $builder->build({ |
|
Lines 92-98
my $jeanpaul_dupont = $builder->build({
Link Here
|
| 92 |
surname => 'Dupont', |
95 |
surname => 'Dupont', |
| 93 |
branchcode => $branchcode, |
96 |
branchcode => $branchcode, |
| 94 |
dateofbirth => '1982-02-01', |
97 |
dateofbirth => '1982-02-01', |
| 95 |
userid => 'jeanpaul.dupont' |
98 |
userid => 'jeanpaul.dupont', |
|
|
99 |
flags => 0, |
| 96 |
}, |
100 |
}, |
| 97 |
}); |
101 |
}); |
| 98 |
my $dupont_brown = $builder->build({ |
102 |
my $dupont_brown = $builder->build({ |
|
Lines 103-109
my $dupont_brown = $builder->build({
Link Here
|
| 103 |
surname => 'Brown', |
107 |
surname => 'Brown', |
| 104 |
branchcode => $branchcode, |
108 |
branchcode => $branchcode, |
| 105 |
dateofbirth => '1979-01-01', |
109 |
dateofbirth => '1979-01-01', |
| 106 |
userid => 'dupont.brown' |
110 |
userid => 'dupont.brown', |
|
|
111 |
flags => 0, |
| 107 |
}, |
112 |
}, |
| 108 |
}); |
113 |
}); |
| 109 |
|
114 |
|
|
Lines 461-465
subtest 'ExtendedPatronAttributes' => sub {
Link Here
|
| 461 |
"'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)"); |
466 |
"'Dupont' is contained in 2 surnames and a patron attribute. Patron attribute one should not be displayed if searching in specific fields (Bug 18094)"); |
| 462 |
}; |
467 |
}; |
| 463 |
|
468 |
|
|
|
469 |
subtest 'Search with permissions' => sub { |
| 470 |
plan tests => 2; |
| 471 |
|
| 472 |
my $superlibrarian = $builder->build_object( |
| 473 |
{ |
| 474 |
class => 'Koha::Patrons', |
| 475 |
value => { branchcode => $branchcode, flags => 1 } |
| 476 |
} |
| 477 |
); |
| 478 |
my $librarian_with_full_permission = $builder->build_object( |
| 479 |
{ |
| 480 |
class => 'Koha::Patrons', |
| 481 |
value => { branchcode => $branchcode, flags => 4100 } |
| 482 |
} |
| 483 |
); # 4100 = 4096 (2^12 suggestions) + 4 (2^2 catalogue) |
| 484 |
my $librarian_with_subpermission = $builder->build_object( |
| 485 |
{ class => 'Koha::Patrons', value => { branchcode => $branchcode } } ); |
| 486 |
C4::Context->dbh->do( |
| 487 |
q|INSERT INTO user_permissions(borrowernumber, module_bit, code) VALUES(?,?,?)|, |
| 488 |
undef, |
| 489 |
$librarian_with_subpermission->borrowernumber, |
| 490 |
12, |
| 491 |
'suggestions_manage' |
| 492 |
); |
| 493 |
|
| 494 |
my $search_results = C4::Utils::DataTables::Members::search( |
| 495 |
{ |
| 496 |
searchmember => "", |
| 497 |
searchfieldstype => 'standard', |
| 498 |
searchtype => 'contain', |
| 499 |
branchcode => $branchcode, |
| 500 |
has_permission => { |
| 501 |
permission => 'suggestions', |
| 502 |
subpermission => 'suggestions_manage' |
| 503 |
}, |
| 504 |
dt_params => { iDisplayLength => 3, iDisplayStart => 0 }, |
| 505 |
} |
| 506 |
); |
| 507 |
is( $search_results->{iTotalDisplayRecords}, |
| 508 |
3, "We find 3 patrons with suggestions_manage permission" ); |
| 509 |
is_deeply( |
| 510 |
[ map { $_->{borrowernumber} } @{ $search_results->{patrons} } ], |
| 511 |
[ |
| 512 |
$superlibrarian->borrowernumber, |
| 513 |
$librarian_with_full_permission->borrowernumber, |
| 514 |
$librarian_with_subpermission->borrowernumber |
| 515 |
], |
| 516 |
'We got the 3 patrons we expected' |
| 517 |
); |
| 518 |
}; |
| 519 |
|
| 464 |
# End |
520 |
# End |
| 465 |
$schema->storage->txn_rollback; |
521 |
$schema->storage->txn_rollback; |
| 466 |
- |
|
|