Lines 19-31
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 |
use Koha::Database; |
23 |
use Koha::Database; |
24 |
|
24 |
|
25 |
use Koha::Biblio; |
25 |
use Koha::Biblio; |
26 |
use Koha::Patron; |
26 |
use Koha::Patron; |
27 |
use Koha::Library; |
27 |
use Koha::Library; |
28 |
|
28 |
|
|
|
29 |
use t::lib::TestBuilder; |
30 |
|
29 |
BEGIN { |
31 |
BEGIN { |
30 |
use_ok('Koha::ArticleRequest'); |
32 |
use_ok('Koha::ArticleRequest'); |
31 |
use_ok('Koha::ArticleRequests'); |
33 |
use_ok('Koha::ArticleRequests'); |
Lines 35-40
BEGIN {
Link Here
|
35 |
my $schema = Koha::Database->new()->schema(); |
37 |
my $schema = Koha::Database->new()->schema(); |
36 |
$schema->storage->txn_begin(); |
38 |
$schema->storage->txn_begin(); |
37 |
|
39 |
|
|
|
40 |
my $builder = t::lib::TestBuilder->new; |
38 |
my $dbh = C4::Context->dbh; |
41 |
my $dbh = C4::Context->dbh; |
39 |
$dbh->{RaiseError} = 1; |
42 |
$dbh->{RaiseError} = 1; |
40 |
|
43 |
|
Lines 65-73
my $patron = Koha::Patron->new(
Link Here
|
65 |
{ |
68 |
{ |
66 |
categorycode => $category->id, |
69 |
categorycode => $category->id, |
67 |
branchcode => $branch->id, |
70 |
branchcode => $branch->id, |
|
|
71 |
flags => 1,# superlibrarian |
68 |
} |
72 |
} |
69 |
)->store(); |
73 |
)->store(); |
70 |
ok( $patron->id, 'Koha::Patron created' ); |
74 |
ok( $patron->id, 'Koha::Patron created' ); |
|
|
75 |
my $patron_2 = $builder->build({ source => 'Borrower' }); |
76 |
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); |
77 |
|
78 |
my $nb_article_requests = Koha::ArticleRequests->count; |
71 |
|
79 |
|
72 |
my $article_request = Koha::ArticleRequest->new( |
80 |
my $article_request = Koha::ArticleRequest->new( |
73 |
{ |
81 |
{ |
Lines 173-176
ok( !$item->can_article_request($patron), 'Item is not requestable with rule t
Link Here
|
173 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
181 |
is( $item->article_request_type($patron), 'no', 'Item article request type is no' ); |
174 |
$rule->delete(); |
182 |
$rule->delete(); |
175 |
|
183 |
|
|
|
184 |
subtest 'search_limited' => sub { |
185 |
plan tests => 2; |
186 |
C4::Context->_new_userenv('xxx'); |
187 |
my $group_1 = Koha::Library::Group->new( { title => 'TEST Group 1' } )->store; |
188 |
my $group_2 = Koha::Library::Group->new( { title => 'TEST Group 2' } )->store; |
189 |
Koha::Library::Group->new({ parent_id => $group_1->id, branchcode => $patron->branchcode })->store(); |
190 |
Koha::Library::Group->new({ parent_id => $group_2->id, branchcode => $patron_2->branchcode })->store(); |
191 |
set_logged_in_user( $patron ); # Is superlibrarian |
192 |
is( Koha::ArticleRequests->count, 3, 'Koha::ArticleRequests should return all article requests' ); |
193 |
is( Koha::ArticleRequests->search_limited->count, 2, 'Koha::ArticleRequests->search_limited should return reviews depending on patron permissions' ); |
194 |
}; |
195 |
|
176 |
$schema->storage->txn_rollback(); |
196 |
$schema->storage->txn_rollback(); |
177 |
- |
197 |
|
|
|
198 |
sub set_logged_in_user { |
199 |
my ($patron) = @_; |
200 |
C4::Context->set_userenv( |
201 |
$patron->borrowernumber, $patron->userid, |
202 |
$patron->cardnumber, 'firstname', |
203 |
'surname', $patron->library->branchcode, |
204 |
'Midway Public Library', $patron->flags, |
205 |
'', '' |
206 |
); |
207 |
} |