|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 6; |
20 |
use Test::More tests => 8; |
| 21 |
use Test::Mojo; |
21 |
use Test::Mojo; |
| 22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 34-39
use Koha::DateUtils;
Link Here
|
| 34 |
use Koha::Biblios; |
34 |
use Koha::Biblios; |
| 35 |
use Koha::Biblioitems; |
35 |
use Koha::Biblioitems; |
| 36 |
use Koha::Items; |
36 |
use Koha::Items; |
|
|
37 |
use Koha::CirculationRules; |
| 37 |
|
38 |
|
| 38 |
my $schema = Koha::Database->new->schema; |
39 |
my $schema = Koha::Database->new->schema; |
| 39 |
my $builder = t::lib::TestBuilder->new(); |
40 |
my $builder = t::lib::TestBuilder->new(); |
|
Lines 267-272
subtest 'Reserves with itemtype' => sub {
Link Here
|
| 267 |
->json_is('/0/item_type', $itemtype); |
268 |
->json_is('/0/item_type', $itemtype); |
| 268 |
}; |
269 |
}; |
| 269 |
|
270 |
|
|
|
271 |
|
| 272 |
subtest 'test AllowHoldDateInFuture' => sub { |
| 273 |
|
| 274 |
plan tests => 6; |
| 275 |
|
| 276 |
$dbh->do('DELETE FROM reserves'); |
| 277 |
|
| 278 |
my $future_hold_date = DateTime->now->add(days => 10)->truncate( to => 'day' ); |
| 279 |
|
| 280 |
my $post_data = { |
| 281 |
patron_id => int($patron_1->borrowernumber), |
| 282 |
biblio_id => int($biblio_1->biblionumber), |
| 283 |
item_id => int($item_1->itemnumber), |
| 284 |
pickup_library_id => $branchcode, |
| 285 |
expiration_date => output_pref({ dt => $expiration_date, dateformat => 'rfc3339', dateonly => 1 }), |
| 286 |
hold_date => output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 }), |
| 287 |
priority => 2, |
| 288 |
}; |
| 289 |
|
| 290 |
t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 0 ); |
| 291 |
|
| 292 |
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) |
| 293 |
->status_is(400) |
| 294 |
->json_has('/error'); |
| 295 |
|
| 296 |
t::lib::Mocks::mock_preference( 'AllowHoldDateInFuture', 1 ); |
| 297 |
|
| 298 |
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) |
| 299 |
->status_is(201) |
| 300 |
->json_is('/hold_date', output_pref({ dt => $future_hold_date, dateformat => 'rfc3339', dateonly => 1 })); |
| 301 |
}; |
| 302 |
|
| 303 |
subtest 'test AllowHoldPolicyOverride' => sub { |
| 304 |
|
| 305 |
plan tests => 5; |
| 306 |
|
| 307 |
$dbh->do('DELETE FROM reserves'); |
| 308 |
|
| 309 |
Koha::CirculationRules->set_rules( |
| 310 |
{ |
| 311 |
categorycode => undef, |
| 312 |
itemtype => undef, |
| 313 |
branchcode => undef, |
| 314 |
rules => { |
| 315 |
holdallowed => 1 |
| 316 |
} |
| 317 |
} |
| 318 |
); |
| 319 |
|
| 320 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 0 ); |
| 321 |
|
| 322 |
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) |
| 323 |
->status_is(403) |
| 324 |
->json_has('/error'); |
| 325 |
|
| 326 |
t::lib::Mocks::mock_preference( 'AllowHoldPolicyOverride', 1 ); |
| 327 |
|
| 328 |
$t->post_ok( "//$userid_3:$password@/api/v1/holds" => json => $post_data ) |
| 329 |
->status_is(201); |
| 330 |
}; |
| 331 |
|
| 270 |
$schema->storage->txn_rollback; |
332 |
$schema->storage->txn_rollback; |
| 271 |
|
333 |
|
| 272 |
subtest 'suspend and resume tests' => sub { |
334 |
subtest 'suspend and resume tests' => sub { |
|
Lines 442-445
subtest 'PUT /holds/{hold_id}/priority tests' => sub {
Link Here
|
| 442 |
is( $hold_3->discard_changes->priority, 3, 'Priority adjusted correctly' ); |
504 |
is( $hold_3->discard_changes->priority, 3, 'Priority adjusted correctly' ); |
| 443 |
|
505 |
|
| 444 |
$schema->storage->txn_rollback; |
506 |
$schema->storage->txn_rollback; |
| 445 |
}; |
507 |
}; |
| 446 |
- |
|
|