Lines 1322-1333
subtest
Link Here
|
1322 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
1322 |
my $library_11 = $builder->build( { source => 'Branch' } ); |
1323 |
my $library_12 = $builder->build( { source => 'Branch' } ); |
1323 |
my $library_12 = $builder->build( { source => 'Branch' } ); |
1324 |
my $library_21 = $builder->build( { source => 'Branch' } ); |
1324 |
my $library_21 = $builder->build( { source => 'Branch' } ); |
|
|
1325 |
my $library_31 = $builder->build( { source => 'Branch' } ); |
1325 |
$library_11 = Koha::Libraries->find( $library_11->{branchcode} ); |
1326 |
$library_11 = Koha::Libraries->find( $library_11->{branchcode} ); |
1326 |
$library_12 = Koha::Libraries->find( $library_12->{branchcode} ); |
1327 |
$library_12 = Koha::Libraries->find( $library_12->{branchcode} ); |
1327 |
$library_21 = Koha::Libraries->find( $library_21->{branchcode} ); |
1328 |
$library_21 = Koha::Libraries->find( $library_21->{branchcode} ); |
|
|
1329 |
$library_31 = Koha::Libraries->find( $library_31->{branchcode} ); |
1328 |
Koha::Library::Group->new( { branchcode => $library_11->branchcode, parent_id => $group_1->id } )->store; |
1330 |
Koha::Library::Group->new( { branchcode => $library_11->branchcode, parent_id => $group_1->id } )->store; |
1329 |
Koha::Library::Group->new( { branchcode => $library_12->branchcode, parent_id => $group_1->id } )->store; |
1331 |
Koha::Library::Group->new( { branchcode => $library_12->branchcode, parent_id => $group_1->id } )->store; |
1330 |
Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store; |
1332 |
Koha::Library::Group->new( { branchcode => $library_21->branchcode, parent_id => $group_2->id } )->store; |
|
|
1333 |
# Library 31, not in any group |
1331 |
|
1334 |
|
1332 |
my $sth = |
1335 |
my $sth = |
1333 |
C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)|); |
1336 |
C4::Context->dbh->prepare(q|INSERT INTO user_permissions( borrowernumber, module_bit, code ) VALUES (?, ?, ?)|); |
Lines 1359-1364
subtest
Link Here
|
1359 |
$patron_21 = Koha::Patrons->find( $patron_21->{borrowernumber} ); |
1362 |
$patron_21 = Koha::Patrons->find( $patron_21->{borrowernumber} ); |
1360 |
$sth->execute( $patron_21->borrowernumber, 4, 'edit_borrowers' ); |
1363 |
$sth->execute( $patron_21->borrowernumber, 4, 'edit_borrowers' ); |
1361 |
|
1364 |
|
|
|
1365 |
# 1 patron from library_31 (no group) can only see patron's info from its library |
1366 |
my $patron_31 = $builder->build( |
1367 |
{ source => 'Borrower', value => { branchcode => $library_31->branchcode, flags => undef, } } ); |
1368 |
$patron_31 = Koha::Patrons->find( $patron_31->{borrowernumber} ); |
1369 |
$sth->execute( $patron_31->borrowernumber, 4, 'edit_borrowers' ); |
1370 |
|
1362 |
# Pfiou, we can start now! |
1371 |
# Pfiou, we can start now! |
1363 |
subtest 'libraries_where_can_see_things' => sub { |
1372 |
subtest 'libraries_where_can_see_things' => sub { |
1364 |
plan tests => 4; |
1373 |
plan tests => 4; |
Lines 1430-1436
subtest
Link Here
|
1430 |
}; |
1439 |
}; |
1431 |
|
1440 |
|
1432 |
subtest 'libraries_where_can_see_patrons' => sub { |
1441 |
subtest 'libraries_where_can_see_patrons' => sub { |
1433 |
plan tests => 3; |
1442 |
plan tests => 4; |
1434 |
|
1443 |
|
1435 |
my @branchcodes; |
1444 |
my @branchcodes; |
1436 |
|
1445 |
|
Lines 1451-1456
subtest
Link Here
|
1451 |
\@branchcodes, [ $library_21->branchcode ], |
1460 |
\@branchcodes, [ $library_21->branchcode ], |
1452 |
q|patron_21 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group| |
1461 |
q|patron_21 has not view_borrower_infos_from_any_libraries => Can only see patron's from its group| |
1453 |
); |
1462 |
); |
|
|
1463 |
|
1464 |
t::lib::Mocks::mock_userenv( { patron => $patron_31 } ); |
1465 |
@branchcodes = $patron_31->libraries_where_can_see_patrons; |
1466 |
is_deeply( |
1467 |
\@branchcodes, [ $library_31->branchcode ], |
1468 |
q|patron_31 has not view_borrower_infos_from_any_libraries => Can only see patron's from its library that is not in a group| |
1469 |
); |
1454 |
}; |
1470 |
}; |
1455 |
subtest 'can_see_patron_infos' => sub { |
1471 |
subtest 'can_see_patron_infos' => sub { |
1456 |
plan tests => 6; |
1472 |
plan tests => 6; |
Lines 1475-1481
subtest
Link Here
|
1475 |
|
1491 |
|
1476 |
t::lib::Mocks::mock_userenv( { patron => $patron_11_1 } ); |
1492 |
t::lib::Mocks::mock_userenv( { patron => $patron_11_1 } ); |
1477 |
$patron_11_1 = Koha::Patrons->find( $patron_11_1->borrowernumber ); |
1493 |
$patron_11_1 = Koha::Patrons->find( $patron_11_1->borrowernumber ); |
1478 |
my $total_number_of_patrons = $nb_of_patrons + 4; #we added four in these tests |
1494 |
my $total_number_of_patrons = $nb_of_patrons + 5; #we added five in these tests |
1479 |
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' ); |
1495 |
is( Koha::Patrons->search->count, $total_number_of_patrons, 'Non-limited search should return all patrons' ); |
1480 |
is( |
1496 |
is( |
1481 |
Koha::Patrons->search_limited->count, $total_number_of_patrons, |
1497 |
Koha::Patrons->search_limited->count, $total_number_of_patrons, |
Lines 1502-1507
subtest
Link Here
|
1502 |
$patron_11_2->delete; |
1518 |
$patron_11_2->delete; |
1503 |
$patron_12->delete; |
1519 |
$patron_12->delete; |
1504 |
$patron_21->delete; |
1520 |
$patron_21->delete; |
|
|
1521 |
$patron_31->delete; |
1505 |
}; |
1522 |
}; |
1506 |
|
1523 |
|
1507 |
subtest 'account_locked' => sub { |
1524 |
subtest 'account_locked' => sub { |