Lines 19-25
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
21 |
|
21 |
|
22 |
use Test::More tests => 54; |
22 |
use Test::More tests => 55; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
|
25 |
|
Lines 27-33
use Koha::Database;
Link Here
|
27 |
use Koha::Biblio; |
27 |
use Koha::Biblio; |
28 |
use Koha::Notice::Messages; |
28 |
use Koha::Notice::Messages; |
29 |
use Koha::Patron; |
29 |
use Koha::Patron; |
30 |
use Koha::Library; |
30 |
|
|
|
31 |
use t::lib::TestBuilder; |
31 |
|
32 |
|
32 |
BEGIN { |
33 |
BEGIN { |
33 |
use_ok('Koha::ArticleRequest'); |
34 |
use_ok('Koha::ArticleRequest'); |
Lines 70-78
my $patron = Koha::Patron->new(
Link Here
|
70 |
{ |
71 |
{ |
71 |
categorycode => $category->{categorycode}, |
72 |
categorycode => $category->{categorycode}, |
72 |
branchcode => $branch->{branchcode}, |
73 |
branchcode => $branch->{branchcode}, |
|
|
74 |
flags => 1,# superlibrarian |
73 |
} |
75 |
} |
74 |
)->store(); |
76 |
)->store(); |
75 |
ok( $patron->id, 'Koha::Patron created' ); |
77 |
ok( $patron->id, 'Koha::Patron created' ); |
|
|
78 |
my $patron_2 = $builder->build({ source => 'Borrower', value => { flags => 0 } }); |
79 |
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); |
80 |
|
81 |
my $nb_article_requests = Koha::ArticleRequests->count; |
76 |
|
82 |
|
77 |
# store |
83 |
# store |
78 |
Koha::Notice::Messages->delete; |
84 |
Koha::Notice::Messages->delete; |
Lines 198-201
ok( !$item->can_article_request($patron), 'Item is not requestable with rule t
Link Here
|
198 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
204 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
199 |
$rule->delete(); |
205 |
$rule->delete(); |
200 |
|
206 |
|
|
|
207 |
subtest 'search_limited' => sub { |
208 |
plan tests => 4; |
209 |
C4::Context->_new_userenv('xxx'); |
210 |
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 |
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 |
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->search_limited->count, $nb_article_requests + 1, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' ); |
217 |
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->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' ); |
220 |
}; |
221 |
|
201 |
$schema->storage->txn_rollback(); |
222 |
$schema->storage->txn_rollback(); |
202 |
- |
223 |
|
|
|
224 |
sub set_logged_in_user { |
225 |
my ($patron) = @_; |
226 |
C4::Context->set_userenv( |
227 |
$patron->borrowernumber, $patron->userid, |
228 |
$patron->cardnumber, 'firstname', |
229 |
'surname', $patron->library->branchcode, |
230 |
'Midway Public Library', $patron->flags, |
231 |
'', '' |
232 |
); |
233 |
} |