View | Details | Raw Unified | Return to bug 37392
Collapse All | Expand All

(-)a/Koha/Patron.pm (-1 / +2 lines)
Lines 2041-2048 sub libraries_where_can_see_things { Link Here
2041
2041
2042
                    }
2042
                    }
2043
                }
2043
                }
2044
            } else {
2045
                push @restricted_branchcodes, $self->branchcode;
2044
            }
2046
            }
2045
2046
        }
2047
        }
2047
    }
2048
    }
2048
2049
(-)a/t/db_dependent/ArticleRequests.t (-2 / +2 lines)
Lines 174-181 subtest 'search_limited' => sub { Link Here
174
    plan tests => 2;
174
    plan tests => 2;
175
    my $nb_article_requests = Koha::ArticleRequests->count;
175
    my $nb_article_requests = Koha::ArticleRequests->count;
176
176
177
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store;
177
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store;
178
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store;
178
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store;
179
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron->branchcode })->store();
179
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron->branchcode })->store();
180
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
180
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
181
    t::lib::Mocks::mock_userenv( { patron => $patron } ); # Is superlibrarian
181
    t::lib::Mocks::mock_userenv( { patron => $patron } ); # Is superlibrarian
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +19 lines)
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 {
(-)a/t/db_dependent/Koha/Reviews.t (-2 / +2 lines)
Lines 70-77 is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id Link Here
70
70
71
subtest 'search_limited' => sub {
71
subtest 'search_limited' => sub {
72
    plan tests => 2;
72
    plan tests => 2;
73
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store;
73
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1  } )->store;
74
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store;
74
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1  } )->store;
75
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron_1->branchcode })->store();
75
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron_1->branchcode })->store();
76
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
76
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
77
    t::lib::Mocks::mock_userenv( { patron => $patron_1 } );
77
    t::lib::Mocks::mock_userenv( { patron => $patron_1 } );
(-)a/t/db_dependent/Patron/Borrower_Discharge.t (-3 / +2 lines)
Lines 154-161 is( ref(Koha::Patron::Discharge::request({ borrowernumber => $patron->borrowernu Link Here
154
subtest 'search_limited' => sub {
154
subtest 'search_limited' => sub {
155
    plan tests => 4;
155
    plan tests => 4;
156
    $dbh->do(q|DELETE FROM discharges|);
156
    $dbh->do(q|DELETE FROM discharges|);
157
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store;
157
    my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1', ft_hide_patron_info => 1 } )->store;
158
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store;
158
    my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2', ft_hide_patron_info => 1 } )->store;
159
    # $patron and $patron2 are from the same library, $patron3 from another one
159
    # $patron and $patron2 are from the same library, $patron3 from another one
160
    # Logged in user is $patron, superlibrarian
160
    # Logged in user is $patron, superlibrarian
161
    t::lib::Mocks::mock_userenv({ patron => $patron });
161
    t::lib::Mocks::mock_userenv({ patron => $patron });
162
- 

Return to bug 37392