Bug 37378: Tidy
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit a0f89e7e98)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7ec7fc7ce0
commit
2dbf64d7ad
|
|
@ -1284,7 +1284,8 @@ subtest 'search_patrons_to_anonymise' => sub {
|
|||
t::lib::Mocks::mock_preference('IndependentBranches', 0);
|
||||
};
|
||||
|
||||
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_see_patron_infos + search_limited' => sub {
|
||||
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_see_patron_infos + search_limited' =>
|
||||
sub {
|
||||
plan tests => 4;
|
||||
|
||||
# group1
|
||||
|
|
@ -1301,30 +1302,36 @@ subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
|
|||
$library_11 = Koha::Libraries->find( $library_11->{branchcode} );
|
||||
$library_12 = Koha::Libraries->find( $library_12->{branchcode} );
|
||||
$library_21 = Koha::Libraries->find( $library_21->{branchcode} );
|
||||
Koha::Library::Group->new(
|
||||
{ branchcode => $library_11->branchcode, parent_id => $group_1->id } )->store;
|
||||
Koha::Library::Group->new(
|
||||
{ branchcode => $library_12->branchcode, parent_id => $group_1->id } )->store;
|
||||
Koha::Library::Group->new(
|
||||
{ branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store;
|
||||
Koha::Library::Group->new( { branchcode => $library_11->branchcode, parent_id => $group_1->id } )->store;
|
||||
Koha::Library::Group->new( { branchcode => $library_12->branchcode, parent_id => $group_1->id } )->store;
|
||||
Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store;
|
||||
|
||||
my $sth = C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, 4, ?)|); # 4 for borrowers
|
||||
my $sth =
|
||||
C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, 4, ?)|)
|
||||
; # 4 for borrowers
|
||||
# 2 patrons from library_11 (group1)
|
||||
# patron_11_1 see patron's infos from outside its group
|
||||
# Setting flags => undef to not be considered as superlibrarian
|
||||
my $patron_11_1 = $builder->build({ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, }});
|
||||
my $patron_11_1 = $builder->build(
|
||||
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } );
|
||||
$patron_11_1 = Koha::Patrons->find( $patron_11_1->{borrowernumber} );
|
||||
$sth->execute( $patron_11_1->borrowernumber, 'edit_borrowers' );
|
||||
$sth->execute( $patron_11_1->borrowernumber, 'view_borrower_infos_from_any_libraries' );
|
||||
|
||||
# patron_11_2 can only see patron's info from its group
|
||||
my $patron_11_2 = $builder->build({ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, }});
|
||||
my $patron_11_2 = $builder->build(
|
||||
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } );
|
||||
$patron_11_2 = Koha::Patrons->find( $patron_11_2->{borrowernumber} );
|
||||
$sth->execute( $patron_11_2->borrowernumber, 'edit_borrowers' );
|
||||
|
||||
# 1 patron from library_12 (group1)
|
||||
my $patron_12 = $builder->build({ source => 'Borrower', value => { branchcode => $library_12->branchcode, flags => undef, }});
|
||||
my $patron_12 = $builder->build(
|
||||
{ source => 'Borrower', value => { branchcode => $library_12->branchcode, flags => undef, } } );
|
||||
$patron_12 = Koha::Patrons->find( $patron_12->{borrowernumber} );
|
||||
|
||||
# 1 patron from library_21 (group2) can only see patron's info from its group
|
||||
my $patron_21 = $builder->build({ source => 'Borrower', value => { branchcode => $library_21->branchcode, flags => undef, }});
|
||||
my $patron_21 = $builder->build(
|
||||
{ source => 'Borrower', value => { branchcode => $library_21->branchcode, flags => undef, } } );
|
||||
$patron_21 = Koha::Patrons->find( $patron_21->{borrowernumber} );
|
||||
$sth->execute( $patron_21->borrowernumber, 'edit_borrowers' );
|
||||
|
||||
|
|
@ -1360,11 +1367,17 @@ subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
|
|||
|
||||
t::lib::Mocks::mock_userenv( { patron => $patron_11_2 } );
|
||||
@branchcodes = $patron_11_2->libraries_where_can_see_patrons;
|
||||
is_deeply( \@branchcodes, [ sort ( $library_11->branchcode, $library_12->branchcode ) ], q|patron_11_2 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group| );
|
||||
is_deeply(
|
||||
\@branchcodes, [ sort ( $library_11->branchcode, $library_12->branchcode ) ],
|
||||
q|patron_11_2 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group|
|
||||
);
|
||||
|
||||
t::lib::Mocks::mock_userenv( { patron => $patron_21 } );
|
||||
@branchcodes = $patron_21->libraries_where_can_see_patrons;
|
||||
is_deeply( \@branchcodes, [$library_21->branchcode], q|patron_21 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group| );
|
||||
is_deeply(
|
||||
\@branchcodes, [ $library_21->branchcode ],
|
||||
q|patron_21 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group|
|
||||
);
|
||||
};
|
||||
subtest 'can_see_patron_infos' => sub {
|
||||
plan tests => 6;
|
||||
|
|
@ -1379,7 +1392,10 @@ subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
|
|||
$patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber );
|
||||
is( $patron_11_2->can_see_patron_infos($patron_11_1), 1, q|patron_11_2 can see patron_11_1, from its library| );
|
||||
is( $patron_11_2->can_see_patron_infos($patron_12), 1, q|patron_11_2 can see patron_12, from its group| );
|
||||
is( $patron_11_2->can_see_patron_infos( $patron_21 ), 0, q|patron_11_2 can NOT see patron_21, from another group| );
|
||||
is(
|
||||
$patron_11_2->can_see_patron_infos($patron_21), 0,
|
||||
q|patron_11_2 can NOT see patron_21, from another group|
|
||||
);
|
||||
};
|
||||
subtest 'search_limited' => sub {
|
||||
plan tests => 6;
|
||||
|
|
@ -1388,17 +1404,26 @@ subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
|
|||
$patron_11_1 = Koha::Patrons->find( $patron_11_1->borrowernumber );
|
||||
my $total_number_of_patrons = $nb_of_patrons + 4; #we added four in these tests
|
||||
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' );
|
||||
is( Koha::Patrons->search_limited->count, $total_number_of_patrons, 'patron_11_1 is allowed to see all patrons' );
|
||||
is(
|
||||
Koha::Patrons->search_limited->count, $total_number_of_patrons,
|
||||
'patron_11_1 is allowed to see all patrons'
|
||||
);
|
||||
|
||||
t::lib::Mocks::mock_userenv( { patron => $patron_11_2 } );
|
||||
$patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber );
|
||||
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' );
|
||||
is( Koha::Patrons->search_limited->count, 3, 'patron_12_1 is not allowed to see patrons from other groups, only patron_11_1, patron_11_2 and patron_12' );
|
||||
is(
|
||||
Koha::Patrons->search_limited->count, 3,
|
||||
'patron_12_1 is not allowed to see patrons from other groups, only patron_11_1, patron_11_2 and patron_12'
|
||||
);
|
||||
|
||||
t::lib::Mocks::mock_userenv( { patron => $patron_21 } );
|
||||
$patron_21 = Koha::Patrons->find( $patron_21->borrowernumber );
|
||||
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' );
|
||||
is( Koha::Patrons->search_limited->count, 1, 'patron_21 is not allowed to see patrons from other groups, only himself' );
|
||||
is(
|
||||
Koha::Patrons->search_limited->count, 1,
|
||||
'patron_21 is not allowed to see patrons from other groups, only himself'
|
||||
);
|
||||
};
|
||||
$patron_11_1->delete;
|
||||
$patron_11_2->delete;
|
||||
|
|
|
|||
Loading…
Reference in New Issue