Lines 19-32
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
21 |
|
21 |
|
22 |
use Test::More tests => 49; |
22 |
use Test::More tests => 50; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
|
25 |
|
26 |
use Koha::Database; |
26 |
use Koha::Database; |
27 |
use Koha::Biblio; |
27 |
use Koha::Biblio; |
28 |
use Koha::Patron; |
28 |
use Koha::Patron; |
29 |
use Koha::Library; |
29 |
|
|
|
30 |
use t::lib::TestBuilder; |
30 |
|
31 |
|
31 |
BEGIN { |
32 |
BEGIN { |
32 |
use_ok('Koha::ArticleRequest'); |
33 |
use_ok('Koha::ArticleRequest'); |
Lines 69-77
my $patron = Koha::Patron->new(
Link Here
|
69 |
{ |
70 |
{ |
70 |
categorycode => $category->{categorycode}, |
71 |
categorycode => $category->{categorycode}, |
71 |
branchcode => $branch->{branchcode}, |
72 |
branchcode => $branch->{branchcode}, |
|
|
73 |
flags => 1,# superlibrarian |
72 |
} |
74 |
} |
73 |
)->store(); |
75 |
)->store(); |
74 |
ok( $patron->id, 'Koha::Patron created' ); |
76 |
ok( $patron->id, 'Koha::Patron created' ); |
|
|
77 |
my $patron_2 = $builder->build({ source => 'Borrower', value => { flags => 0 } }); |
78 |
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); |
79 |
|
80 |
my $nb_article_requests = Koha::ArticleRequests->count; |
75 |
|
81 |
|
76 |
my $article_request = Koha::ArticleRequest->new( |
82 |
my $article_request = Koha::ArticleRequest->new( |
77 |
{ |
83 |
{ |
Lines 177-180
ok( !$item->can_article_request($patron), 'Item is not requestable with rule t
Link Here
|
177 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
183 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
178 |
$rule->delete(); |
184 |
$rule->delete(); |
179 |
|
185 |
|
|
|
186 |
subtest 'search_limited' => sub { |
187 |
plan tests => 4; |
188 |
C4::Context->_new_userenv('xxx'); |
189 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store; |
190 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store; |
191 |
Koha::Library::Group->new({ parent_id => $group_1->id, branchcode => $patron->branchcode })->store(); |
192 |
Koha::Library::Group->new({ parent_id => $group_2->id, branchcode => $patron_2->branchcode })->store(); |
193 |
set_logged_in_user( $patron ); # Is superlibrarian |
194 |
is( Koha::ArticleRequests->count, $nb_article_requests + 1, 'Koha::ArticleRequests should return all article requests' ); |
195 |
is( Koha::ArticleRequests->search_limited->count, $nb_article_requests + 1, 'Koha::ArticleRequests->search_limited should return all article requests for superlibrarian' ); |
196 |
set_logged_in_user( $patron_2 ); # Is restricted |
197 |
is( Koha::ArticleRequests->count, $nb_article_requests + 1, 'Koha::ArticleRequests should return all article requests' ); |
198 |
is( Koha::ArticleRequests->search_limited->count, $nb_article_requests, 'Koha::ArticleRequests->search_limited should not return all article requests for restricted patron' ); |
199 |
}; |
200 |
|
180 |
$schema->storage->txn_rollback(); |
201 |
$schema->storage->txn_rollback(); |
181 |
- |
202 |
|
|
|
203 |
sub set_logged_in_user { |
204 |
my ($patron) = @_; |
205 |
C4::Context->set_userenv( |
206 |
$patron->borrowernumber, $patron->userid, |
207 |
$patron->cardnumber, 'firstname', |
208 |
'surname', $patron->library->branchcode, |
209 |
'Midway Public Library', $patron->flags, |
210 |
'', '' |
211 |
); |
212 |
} |