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