|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 16; |
20 |
use Test::More tests => 17; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
| 23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
|
Lines 518-523
subtest 'suspend and resume tests' => sub {
Link Here
|
| 518 |
$schema->storage->txn_rollback; |
518 |
$schema->storage->txn_rollback; |
| 519 |
}; |
519 |
}; |
| 520 |
|
520 |
|
|
|
521 |
subtest 'suspend bulk tests' => sub { |
| 522 |
|
| 523 |
plan tests => 16; |
| 524 |
|
| 525 |
$schema->storage->txn_begin; |
| 526 |
|
| 527 |
my $password = 'AbcdEFG123'; |
| 528 |
|
| 529 |
my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { userid => 'tomasito', flags => 0 } } ); |
| 530 |
$builder->build( |
| 531 |
{ |
| 532 |
source => 'UserPermission', |
| 533 |
value => { |
| 534 |
borrowernumber => $patron->borrowernumber, |
| 535 |
module_bit => 6, |
| 536 |
code => 'place_holds', |
| 537 |
}, |
| 538 |
} |
| 539 |
); |
| 540 |
|
| 541 |
$patron->set_password( { password => $password, skip_validation => 1 } ); |
| 542 |
my $userid = $patron->userid; |
| 543 |
|
| 544 |
# Disable logging |
| 545 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
| 546 |
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); |
| 547 |
|
| 548 |
my $hold = $builder->build_object( |
| 549 |
{ |
| 550 |
class => 'Koha::Holds', |
| 551 |
value => { suspend => 0, suspend_until => undef, waitingdate => undef, found => undef } |
| 552 |
} |
| 553 |
); |
| 554 |
|
| 555 |
my $hold_2 = $builder->build_object( |
| 556 |
{ |
| 557 |
class => 'Koha::Holds', |
| 558 |
value => { suspend => 0, suspend_until => undef, waitingdate => undef, found => undef } |
| 559 |
} |
| 560 |
); |
| 561 |
|
| 562 |
ok( !$hold->is_suspended, 'Hold is not suspended' ); |
| 563 |
ok( !$hold_2->is_suspended, 'Hold is not suspended' ); |
| 564 |
|
| 565 |
$t->post_ok( |
| 566 |
"//$userid:$password@/api/v1/holds/suspension_bulk" => json => { hold_ids => [ $hold->id, $hold_2->id ] } ) |
| 567 |
->status_is( 201, 'Hold bulk suspension created' ); |
| 568 |
|
| 569 |
$hold->discard_changes; |
| 570 |
$hold_2->discard_changes; |
| 571 |
|
| 572 |
ok( $hold->is_suspended, 'Hold is suspended' ); |
| 573 |
ok( $hold_2->is_suspended, 'Hold is suspended' ); |
| 574 |
|
| 575 |
$hold->resume; |
| 576 |
$hold_2->resume; |
| 577 |
|
| 578 |
ok( !$hold->is_suspended, 'Hold is not suspended' ); |
| 579 |
ok( !$hold_2->is_suspended, 'Hold is not suspended' ); |
| 580 |
|
| 581 |
$t->post_ok( "//$userid:$password@/api/v1/holds/suspension_bulk" => json => |
| 582 |
{ end_date => "2024-07-30", hold_ids => [ $hold->id, $hold_2->id ] } ) |
| 583 |
->status_is( 201, 'Hold bulk suspension created' ) |
| 584 |
->json_is( { end_date => "2024-07-30", hold_ids => [ $hold->id, $hold_2->id ] } ); |
| 585 |
|
| 586 |
$hold->discard_changes; |
| 587 |
$hold_2->discard_changes; |
| 588 |
|
| 589 |
$hold_2->delete; |
| 590 |
|
| 591 |
$hold->resume; |
| 592 |
ok( !$hold->is_suspended, 'Hold is not suspended' ); |
| 593 |
|
| 594 |
$t->post_ok( "//$userid:$password@/api/v1/holds/suspension_bulk" => json => { hold_ids => [ $hold_2->id ] } ) |
| 595 |
->status_is( 404, 'Hold bulk suspension failed. Hold not found' ); |
| 596 |
ok( !$hold->is_suspended, 'Hold is not suspended. Bulk suspension failed' ); |
| 597 |
|
| 598 |
$hold->discard_changes; |
| 599 |
|
| 600 |
ok( !$hold->is_suspended, 'Hold is not suspended. Bulk suspension failed' ); |
| 601 |
|
| 602 |
$schema->storage->txn_rollback; |
| 603 |
}; |
| 604 |
|
| 521 |
subtest 'PUT /holds/{hold_id}/priority tests' => sub { |
605 |
subtest 'PUT /holds/{hold_id}/priority tests' => sub { |
| 522 |
|
606 |
|
| 523 |
plan tests => 14; |
607 |
plan tests => 14; |
| 524 |
- |
|
|