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 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
Lines 252-255
subtest 'may_article_request' => sub {
Link Here
|
252 |
$cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY ); |
252 |
$cache->clear_from_cache( Koha::CirculationRules::GUESSED_ITEMTYPES_KEY ); |
253 |
}; |
253 |
}; |
254 |
|
254 |
|
|
|
255 |
subtest 'article request fee' => sub { |
256 |
plan tests => 10; |
257 |
|
258 |
t::lib::Mocks::mock_preference('ArticleRequests', 1); |
259 |
|
260 |
my $item = $builder->build_sample_item; |
261 |
|
262 |
my $category = $builder->build_object( |
263 |
{ |
264 |
class => 'Koha::Patron::Categories', |
265 |
value => { |
266 |
article_request_fee => undef |
267 |
} |
268 |
} |
269 |
); |
270 |
my $patron = $builder->build_object( |
271 |
{ |
272 |
class => 'Koha::Patrons', |
273 |
value => { |
274 |
categorycode => $category->categorycode |
275 |
}, |
276 |
} |
277 |
); |
278 |
$patron->account->lines->delete(); |
279 |
|
280 |
my $article_request_1 = Koha::ArticleRequest->new( |
281 |
{ |
282 |
borrowernumber => $patron->id, |
283 |
biblionumber => $item->biblionumber, |
284 |
itemnumber => $item->itemnumber, |
285 |
title => 'an article request', |
286 |
} |
287 |
)->store(); |
288 |
|
289 |
is($patron->account->balance, 0, 'There are no account lines'); |
290 |
is($patron->article_requests_current->count, 1, 'There is one current article request'); |
291 |
|
292 |
$category->article_request_fee(10)->store(); |
293 |
|
294 |
my $article_request_2 = Koha::ArticleRequest->new( |
295 |
{ |
296 |
borrowernumber => $patron->id, |
297 |
biblionumber => $item->biblionumber, |
298 |
itemnumber => $item->itemnumber, |
299 |
title => 'an second article request', |
300 |
} |
301 |
)->store(); |
302 |
|
303 |
is($patron->account->balance, 10, 'Patron owes 10'); |
304 |
is($patron->article_requests_current->count, 2, 'There are 2 current article requests'); |
305 |
|
306 |
$category->article_request_fee(20)->store(); |
307 |
|
308 |
my $article_request_3 = Koha::ArticleRequest->new( |
309 |
{ |
310 |
borrowernumber => $patron->id, |
311 |
biblionumber => $item->biblionumber, |
312 |
itemnumber => $item->itemnumber, |
313 |
title => 'an third article request', |
314 |
} |
315 |
)->store(); |
316 |
|
317 |
is($patron->account->balance, 30, 'Patron owes 30'); |
318 |
is($patron->article_requests_current->count, 3, 'There are 3 current article requests'); |
319 |
|
320 |
$article_request_2->cancel(); |
321 |
|
322 |
is($patron->account->balance, 20, 'Patron owes 20'); |
323 |
is($patron->article_requests_current->count, 2, 'There are 2 current article requests'); |
324 |
|
325 |
$article_request_3->cancel(); |
326 |
|
327 |
is($patron->account->balance, 0, 'There are no account lines'); |
328 |
is($patron->article_requests_current->count, 1, 'There is one current article request'); |
329 |
|
330 |
}; |
331 |
|
255 |
$schema->storage->txn_rollback(); |
332 |
$schema->storage->txn_rollback(); |