Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 117; |
20 |
use Test::More tests => 118; |
21 |
|
21 |
|
22 |
use DateTime; |
22 |
use DateTime; |
23 |
use POSIX qw( floor ); |
23 |
use POSIX qw( floor ); |
Lines 2227-2232
subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub {
Link Here
|
2227 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
2227 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
2228 |
}; |
2228 |
}; |
2229 |
|
2229 |
|
|
|
2230 |
subtest 'CanBookBeIssued | notforloan' => sub { |
2231 |
plan tests => 2; |
2232 |
|
2233 |
t::lib::Mocks::mock_preference('AllowNotForLoanOverride', 0); |
2234 |
|
2235 |
my $library = $builder->build( { source => 'Branch' } ); |
2236 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store; |
2237 |
|
2238 |
my $itemtype = $builder->build( |
2239 |
{ |
2240 |
source => 'Itemtype', |
2241 |
value => { notforloan => undef, } |
2242 |
} |
2243 |
); |
2244 |
|
2245 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
2246 |
my $item = $builder->build_object( |
2247 |
{ |
2248 |
class => 'Koha::Items', |
2249 |
value => { |
2250 |
homebranch => $library->{branchcode}, |
2251 |
holdingbranch => $library->{branchcode}, |
2252 |
notforloan => 0, |
2253 |
itemlost => 0, |
2254 |
withdrawn => 0, |
2255 |
itype => $itemtype->{itemtype}, |
2256 |
biblionumber => $biblioitem->{biblionumber}, |
2257 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
2258 |
} |
2259 |
} |
2260 |
)->store; |
2261 |
|
2262 |
my ( $issuingimpossible, $needsconfirmation ); |
2263 |
|
2264 |
|
2265 |
subtest 'item-level_itypes = 1' => sub { |
2266 |
plan tests => 6; |
2267 |
|
2268 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); # item |
2269 |
# Is for loan at item type and item level |
2270 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2271 |
is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); |
2272 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
2273 |
|
2274 |
# not for loan at item type level |
2275 |
Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(1)->store; |
2276 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2277 |
is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); |
2278 |
is_deeply( |
2279 |
$issuingimpossible, |
2280 |
{ NOT_FOR_LOAN => 1, itemtype_notforloan => $itemtype->{itemtype} }, |
2281 |
'Item can not be issued, not for loan at item type level' |
2282 |
); |
2283 |
|
2284 |
# not for loan at item level |
2285 |
Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(undef)->store; |
2286 |
$item->notforloan( 1 )->store; |
2287 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2288 |
is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); |
2289 |
is_deeply( |
2290 |
$issuingimpossible, |
2291 |
{ NOT_FOR_LOAN => 1, item_notforloan => 1 }, |
2292 |
'Item can not be issued, not for loan at item type level' |
2293 |
); |
2294 |
}; |
2295 |
|
2296 |
subtest 'item-level_itypes = 0' => sub { |
2297 |
plan tests => 6; |
2298 |
|
2299 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); # biblio |
2300 |
|
2301 |
# We set another itemtype for biblioitem |
2302 |
my $itemtype = $builder->build( |
2303 |
{ |
2304 |
source => 'Itemtype', |
2305 |
value => { notforloan => undef, } |
2306 |
} |
2307 |
); |
2308 |
|
2309 |
# for loan at item type and item level |
2310 |
$item->notforloan(undef)->store; |
2311 |
$item->biblioitem->itemtype($itemtype->{itemtype})->store; |
2312 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2313 |
is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); |
2314 |
is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); |
2315 |
|
2316 |
# not for loan at item type level |
2317 |
Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(1)->store; |
2318 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2319 |
is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); |
2320 |
is_deeply( |
2321 |
$issuingimpossible, |
2322 |
{ NOT_FOR_LOAN => 1, itemtype_notforloan => $itemtype->{itemtype} }, |
2323 |
'Item can not be issued, not for loan at item type level' |
2324 |
); |
2325 |
|
2326 |
# not for loan at item level |
2327 |
Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(undef)->store; |
2328 |
$item->notforloan( 1 )->store; |
2329 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); |
2330 |
is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); |
2331 |
is_deeply( |
2332 |
$issuingimpossible, |
2333 |
{ NOT_FOR_LOAN => 1, item_notforloan => 1 }, |
2334 |
'Item can not be issued, not for loan at item type level' |
2335 |
); |
2336 |
}; |
2337 |
|
2338 |
# TODO test with AllowNotForLoanOverride = 1 |
2339 |
}; |
2340 |
|
2230 |
$schema->storage->txn_rollback; |
2341 |
$schema->storage->txn_rollback; |
2231 |
$cache->clear_from_cache('single_holidays'); |
2342 |
$cache->clear_from_cache('single_holidays'); |
2232 |
|
2343 |
|
2233 |
- |
|
|