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

(-)a/t/db_dependent/ArticleRequests.t (-11 / +7 lines)
Lines 67-83 ok( $item->id, 'Koha::Item created' ); Link Here
67
67
68
my $branch   = $builder->build({ source => 'Branch' });
68
my $branch   = $builder->build({ source => 'Branch' });
69
my $category = $builder->build({ source => 'Category' });
69
my $category = $builder->build({ source => 'Category' });
70
my $patron   = Koha::Patron->new(
70
my $patron   = $builder->build_object({
71
    {
71
    class => 'Koha::Patrons',
72
    value => {
72
        categorycode => $category->{categorycode},
73
        categorycode => $category->{categorycode},
73
        branchcode   => $branch->{branchcode},
74
        branchcode   => $branch->{branchcode},
74
        flags        => 1,# superlibrarian
75
        flags        => 1,# superlibrarian
75
        userid       => 'a_userid_for_tests', # So far Koha::Patron->store does not deal with userid, see bug 20287
76
    },
76
    }
77
});
77
)->store();
78
ok( $patron->id, 'Koha::Patron created' );
78
ok( $patron->id, 'Koha::Patron created' );
79
my $patron_2 = $builder->build({ source => 'Borrower', value => { flags => 0 } });
79
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value => { flags => 0 } });
80
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} );
81
80
82
# store
81
# store
83
Koha::Notice::Messages->delete;
82
Koha::Notice::Messages->delete;
Lines 204-210 is( $item->article_request_type($patron), 'no', 'Item article request type is no Link Here
204
$rule->delete();
203
$rule->delete();
205
204
206
subtest 'search_limited' => sub {
205
subtest 'search_limited' => sub {
207
    plan tests => 4;
206
    plan tests => 2;
208
    C4::Context->_new_userenv('xxx');
207
    C4::Context->_new_userenv('xxx');
209
    my $nb_article_requests = Koha::ArticleRequests->count;
208
    my $nb_article_requests = Koha::ArticleRequests->count;
210
209
Lines 213-222 subtest 'search_limited' => sub { Link Here
213
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron->branchcode })->store();
212
    Koha::Library::Group->new({ parent_id => $group_1->id,  branchcode => $patron->branchcode })->store();
214
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
213
    Koha::Library::Group->new({ parent_id => $group_2->id,  branchcode => $patron_2->branchcode })->store();
215
    set_logged_in_user( $patron ); # Is superlibrarian
214
    set_logged_in_user( $patron ); # Is superlibrarian
216
    is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' );
217
    is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' );
215
    is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' );
218
    set_logged_in_user( $patron_2 ); # Is restricted
216
    set_logged_in_user( $patron_2 ); # Is restricted
219
    is( Koha::ArticleRequests->count, $nb_article_requests, 'Koha::ArticleRequests should return all article requests' );
220
    is( Koha::ArticleRequests->search_limited->count, 0, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' );
217
    is( Koha::ArticleRequests->search_limited->count, 0, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' );
221
};
218
};
222
219
223
- 

Return to bug 20866