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

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

Return to bug 20866