Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 51; |
20 |
use Test::More tests => 52; |
21 |
|
21 |
|
22 |
use C4::Context; |
22 |
use C4::Context; |
23 |
use C4::Members; |
23 |
use C4::Members; |
Lines 56-62
my $john_doe = $builder->build({
Link Here
|
56 |
branchcode => $branchcode, |
56 |
branchcode => $branchcode, |
57 |
dateofbirth => '1983-03-01', |
57 |
dateofbirth => '1983-03-01', |
58 |
userid => 'john.doe', |
58 |
userid => 'john.doe', |
59 |
initials => 'pacman' |
59 |
initials => 'pacman', |
|
|
60 |
flags => 0, |
60 |
}, |
61 |
}, |
61 |
}); |
62 |
}); |
62 |
|
63 |
|
Lines 68-74
my $john_smith = $builder->build({
Link Here
|
68 |
surname => 'Smith', |
69 |
surname => 'Smith', |
69 |
branchcode => $branchcode, |
70 |
branchcode => $branchcode, |
70 |
dateofbirth => '1982-02-01', |
71 |
dateofbirth => '1982-02-01', |
71 |
userid => 'john.smith' |
72 |
userid => 'john.smith', |
|
|
73 |
flags => 0, |
72 |
}, |
74 |
}, |
73 |
}); |
75 |
}); |
74 |
|
76 |
|
Lines 80-86
my $jane_doe = $builder->build({
Link Here
|
80 |
surname => 'Doe', |
82 |
surname => 'Doe', |
81 |
branchcode => $branchcode, |
83 |
branchcode => $branchcode, |
82 |
dateofbirth => '1983-03-01', |
84 |
dateofbirth => '1983-03-01', |
83 |
userid => 'jane.doe' |
85 |
userid => 'jane.doe', |
|
|
86 |
flags => 0, |
84 |
}, |
87 |
}, |
85 |
}); |
88 |
}); |
86 |
my $jeanpaul_dupont = $builder->build({ |
89 |
my $jeanpaul_dupont = $builder->build({ |
Lines 91-97
my $jeanpaul_dupont = $builder->build({
Link Here
|
91 |
surname => 'Dupont', |
94 |
surname => 'Dupont', |
92 |
branchcode => $branchcode, |
95 |
branchcode => $branchcode, |
93 |
dateofbirth => '1982-02-01', |
96 |
dateofbirth => '1982-02-01', |
94 |
userid => 'jeanpaul.dupont' |
97 |
userid => 'jeanpaul.dupont', |
|
|
98 |
flags => 0, |
95 |
}, |
99 |
}, |
96 |
}); |
100 |
}); |
97 |
my $dupont_brown = $builder->build({ |
101 |
my $dupont_brown = $builder->build({ |
Lines 102-108
my $dupont_brown = $builder->build({
Link Here
|
102 |
surname => 'Brown', |
106 |
surname => 'Brown', |
103 |
branchcode => $branchcode, |
107 |
branchcode => $branchcode, |
104 |
dateofbirth => '1979-01-01', |
108 |
dateofbirth => '1979-01-01', |
105 |
userid => 'dupont.brown' |
109 |
userid => 'dupont.brown', |
|
|
110 |
flags => 0, |
106 |
}, |
111 |
}, |
107 |
}); |
112 |
}); |
108 |
|
113 |
|
Lines 495-499
subtest 'Search by any borrowers field (bug 17374)' => sub {
Link Here
|
495 |
is( $search_results->{ patrons }[0]->{ cardnumber }, $john_doe->{cardnumber}, "We find the correct patron when sesrching by initials" ) |
500 |
is( $search_results->{ patrons }[0]->{ cardnumber }, $john_doe->{cardnumber}, "We find the correct patron when sesrching by initials" ) |
496 |
}; |
501 |
}; |
497 |
|
502 |
|
|
|
503 |
subtest 'Search with permissions' => sub { |
504 |
plan tests => 2; |
505 |
|
506 |
my $superlibrarian = $builder->build_object( |
507 |
{ |
508 |
class => 'Koha::Patrons', |
509 |
value => { branchcode => $branchcode, flags => 1 } |
510 |
} |
511 |
); |
512 |
my $librarian_with_full_permission = $builder->build_object( |
513 |
{ |
514 |
class => 'Koha::Patrons', |
515 |
value => { branchcode => $branchcode, flags => 4100 } |
516 |
} |
517 |
); # 4100 = 4096 (2^12 suggestions) + 4 (2^2 catalogue) |
518 |
my $librarian_with_subpermission = $builder->build_object( |
519 |
{ class => 'Koha::Patrons', value => { branchcode => $branchcode } } ); |
520 |
C4::Context->dbh->do( |
521 |
q|INSERT INTO user_permissions(borrowernumber, module_bit, code) VALUES(?,?,?)|, |
522 |
undef, |
523 |
$librarian_with_subpermission->borrowernumber, |
524 |
12, |
525 |
'suggestions_manage' |
526 |
); |
527 |
|
528 |
my $search_results = C4::Utils::DataTables::Members::search( |
529 |
{ |
530 |
searchmember => "", |
531 |
searchfieldstype => 'standard', |
532 |
searchtype => 'contain', |
533 |
branchcode => $branchcode, |
534 |
has_permission => { |
535 |
permission => 'suggestions', |
536 |
subpermission => 'suggestions_manage' |
537 |
}, |
538 |
dt_params => { iDisplayLength => 3, iDisplayStart => 0 }, |
539 |
} |
540 |
); |
541 |
is( $search_results->{iTotalDisplayRecords}, |
542 |
3, "We find 3 patrons with suggestions_manage permission" ); |
543 |
is_deeply( |
544 |
[ map { $_->{borrowernumber} } @{ $search_results->{patrons} } ], |
545 |
[ |
546 |
$superlibrarian->borrowernumber, |
547 |
$librarian_with_full_permission->borrowernumber, |
548 |
$librarian_with_subpermission->borrowernumber |
549 |
], |
550 |
'We got the 3 patrons we expected' |
551 |
); |
552 |
}; |
553 |
|
498 |
# End |
554 |
# End |
499 |
$schema->storage->txn_rollback; |
555 |
$schema->storage->txn_rollback; |
500 |
- |
|
|