Lines 1284-1292
subtest 'search_patrons_to_anonymise' => sub {
Link Here
|
1284 |
t::lib::Mocks::mock_preference('IndependentBranches', 0); |
1284 |
t::lib::Mocks::mock_preference('IndependentBranches', 0); |
1285 |
}; |
1285 |
}; |
1286 |
|
1286 |
|
1287 |
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_see_patron_infos + search_limited' => |
1287 |
subtest |
1288 |
sub { |
1288 |
'libraries_where_can_see_patrons + libraries_where_can_see_things + can_see_patron_infos + search_limited+ can_see_patrons_from + can_edit_items_from' |
1289 |
plan tests => 4; |
1289 |
=> sub { |
|
|
1290 |
plan tests => 6; |
1290 |
|
1291 |
|
1291 |
# group1 |
1292 |
# group1 |
1292 |
# + library_11 |
1293 |
# + library_11 |
Lines 1294-1301
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
Link Here
|
1294 |
# group2 |
1295 |
# group2 |
1295 |
# + library21 |
1296 |
# + library21 |
1296 |
$nb_of_patrons = Koha::Patrons->search->count; |
1297 |
$nb_of_patrons = Koha::Patrons->search->count; |
1297 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store; |
1298 |
my $group_1 = |
1298 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store; |
1299 |
Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } ) |
|
|
1300 |
->store; |
1301 |
my $group_2 = |
1302 |
Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } ) |
1303 |
->store; |
1299 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
1304 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
1300 |
my $library_12 = $builder->build( { source => 'Branch' } ); |
1305 |
my $library_12 = $builder->build( { source => 'Branch' } ); |
1301 |
my $library_21 = $builder->build( { source => 'Branch' } ); |
1306 |
my $library_21 = $builder->build( { source => 'Branch' } ); |
Lines 1307-1328
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
Link Here
|
1307 |
Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store; |
1312 |
Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store; |
1308 |
|
1313 |
|
1309 |
my $sth = |
1314 |
my $sth = |
1310 |
C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, 4, ?)|) |
1315 |
C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)|) |
1311 |
; # 4 for borrowers |
1316 |
; |
1312 |
# 2 patrons from library_11 (group1) |
1317 |
# 2 patrons from library_11 (group1) |
1313 |
# patron_11_1 see patron's infos from outside its group |
1318 |
# patron_11_1 see patron's infos from outside its group |
1314 |
# Setting flags => undef to not be considered as superlibrarian |
1319 |
# Setting flags => undef to not be considered as superlibrarian |
1315 |
my $patron_11_1 = $builder->build( |
1320 |
my $patron_11_1 = $builder->build( |
1316 |
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } ); |
1321 |
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } ); |
1317 |
$patron_11_1 = Koha::Patrons->find( $patron_11_1->{borrowernumber} ); |
1322 |
$patron_11_1 = Koha::Patrons->find( $patron_11_1->{borrowernumber} ); |
1318 |
$sth->execute( $patron_11_1->borrowernumber, 'edit_borrowers' ); |
1323 |
$sth->execute( $patron_11_1->borrowernumber, 4, 'edit_borrowers' ); |
1319 |
$sth->execute( $patron_11_1->borrowernumber, 'view_borrower_infos_from_any_libraries' ); |
1324 |
$sth->execute( $patron_11_1->borrowernumber, 4,'view_borrower_infos_from_any_libraries' ); |
1320 |
|
1325 |
|
1321 |
# patron_11_2 can only see patron's info from its group |
1326 |
# patron_11_2 can only see patron's info from its group |
1322 |
my $patron_11_2 = $builder->build( |
1327 |
my $patron_11_2 = $builder->build( |
1323 |
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } ); |
1328 |
{ source => 'Borrower', value => { branchcode => $library_11->branchcode, flags => undef, } } ); |
1324 |
$patron_11_2 = Koha::Patrons->find( $patron_11_2->{borrowernumber} ); |
1329 |
$patron_11_2 = Koha::Patrons->find( $patron_11_2->{borrowernumber} ); |
1325 |
$sth->execute( $patron_11_2->borrowernumber, 'edit_borrowers' ); |
1330 |
$sth->execute( $patron_11_2->borrowernumber, 4, 'edit_borrowers' ); |
|
|
1331 |
$sth->execute( $patron_11_2->borrowernumber, 9, 'edit_items' ); |
1326 |
|
1332 |
|
1327 |
# 1 patron from library_12 (group1) |
1333 |
# 1 patron from library_12 (group1) |
1328 |
my $patron_12 = $builder->build( |
1334 |
my $patron_12 = $builder->build( |
Lines 1333-1339
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
Link Here
|
1333 |
my $patron_21 = $builder->build( |
1339 |
my $patron_21 = $builder->build( |
1334 |
{ source => 'Borrower', value => { branchcode => $library_21->branchcode, flags => undef, } } ); |
1340 |
{ source => 'Borrower', value => { branchcode => $library_21->branchcode, flags => undef, } } ); |
1335 |
$patron_21 = Koha::Patrons->find( $patron_21->{borrowernumber} ); |
1341 |
$patron_21 = Koha::Patrons->find( $patron_21->{borrowernumber} ); |
1336 |
$sth->execute( $patron_21->borrowernumber, 'edit_borrowers' ); |
1342 |
$sth->execute( $patron_21->borrowernumber, 4, 'edit_borrowers' ); |
1337 |
|
1343 |
|
1338 |
# Pfiou, we can start now! |
1344 |
# Pfiou, we can start now! |
1339 |
subtest 'libraries_where_can_see_things' => sub { |
1345 |
subtest 'libraries_where_can_see_things' => sub { |
Lines 1356-1361
subtest 'libraries_where_can_see_patrons + libraries_where_can_see_things + can_
Link Here
|
1356 |
); |
1362 |
); |
1357 |
}; |
1363 |
}; |
1358 |
|
1364 |
|
|
|
1365 |
subtest 'can_see_patrons_from' => sub { |
1366 |
plan tests => 2; |
1367 |
ok( $patron_11_2->can_see_patrons_from( $library_11->branchcode ), "We can see a patron from in our group" ); |
1368 |
ok( |
1369 |
!$patron_11_2->can_see_patrons_from( $library_21->branchcode ), |
1370 |
"We cannot see a patron from outside our group without permissions" |
1371 |
); |
1372 |
}; |
1373 |
|
1374 |
subtest 'can_edit_items_from' => sub { |
1375 |
plan tests => 4; |
1376 |
ok( $patron_11_2->can_edit_items_from( $library_11->branchcode ), "We can edit an item from in our group" ); |
1377 |
ok( |
1378 |
$patron_11_2->can_edit_items_from( $library_21->branchcode ), |
1379 |
"We can edit an item from outside our group as the group does not limit item editing" |
1380 |
); |
1381 |
$group_2->ft_limit_item_editing(1)->store(); |
1382 |
|
1383 |
$patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber ); |
1384 |
#FIXME We refetch the patron because library lists are cached in an extra hash key |
1385 |
# in libraries_where_can_see_things |
1386 |
|
1387 |
ok( |
1388 |
!$patron_11_2->can_edit_items_from( $library_21->branchcode ), |
1389 |
"We can not edit an item from outside our group as the group does limit item editing" |
1390 |
); |
1391 |
|
1392 |
$sth->execute( $patron_11_2->borrowernumber, 9, 'edit_any_item' ); |
1393 |
$patron_11_2 = Koha::Patrons->find( $patron_11_2->borrowernumber ); |
1394 |
|
1395 |
ok( |
1396 |
$patron_11_2->can_edit_items_from( $library_21->branchcode ), |
1397 |
"We can edit an item from outside our group as we have permission" |
1398 |
); |
1399 |
|
1400 |
}; |
1401 |
|
1359 |
subtest 'libraries_where_can_see_patrons' => sub { |
1402 |
subtest 'libraries_where_can_see_patrons' => sub { |
1360 |
plan tests => 3; |
1403 |
plan tests => 3; |
1361 |
|
1404 |
|
1362 |
- |
|
|