Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 70; |
20 |
use Test::More tests => 71; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 31-37
use C4::Circulation qw( AddReturn AddIssue );
Link Here
|
31 |
use C4::Items; |
31 |
use C4::Items; |
32 |
use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblio ); |
32 |
use C4::Biblio qw( GetMarcBiblio GetMarcFromKohaField ModBiblio ); |
33 |
use C4::Members; |
33 |
use C4::Members; |
34 |
use C4::Reserves qw( AddReserve CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds ); |
34 |
use C4::Reserves qw( AddReserve AlterPriority CheckReserves GetReservesControlBranch ModReserve ModReserveAffect ReserveSlip CalculatePriority CanReserveBeCanceledFromOpac CanBookBeReserved IsAvailableForItemLevelRequest MoveReserve ChargeReserveFee RevertWaitingStatus CanItemBeReserved MergeHolds ); |
35 |
use Koha::ActionLogs; |
35 |
use Koha::ActionLogs; |
36 |
use Koha::Caches; |
36 |
use Koha::Caches; |
37 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
37 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
Lines 934-940
subtest 'reserves.item_level_hold' => sub {
Link Here
|
934 |
); |
934 |
); |
935 |
|
935 |
|
936 |
subtest 'item level hold' => sub { |
936 |
subtest 'item level hold' => sub { |
937 |
plan tests => 2; |
937 |
plan tests => 3; |
938 |
my $reserve_id = AddReserve( |
938 |
my $reserve_id = AddReserve( |
939 |
{ |
939 |
{ |
940 |
branchcode => $item->homebranch, |
940 |
branchcode => $item->homebranch, |
Lines 951-956
subtest 'reserves.item_level_hold' => sub {
Link Here
|
951 |
# Mark it waiting |
951 |
# Mark it waiting |
952 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
952 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
953 |
|
953 |
|
|
|
954 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
955 |
$mock->mock( 'enqueue', sub { |
956 |
my ( $self, $args ) = @_; |
957 |
is_deeply( |
958 |
$args->{biblio_ids}, |
959 |
[ $hold->biblionumber ], |
960 |
"AlterPriority triggers a holds queue update for the related biblio" |
961 |
); |
962 |
} ); |
963 |
|
954 |
# Revert the waiting status |
964 |
# Revert the waiting status |
955 |
C4::Reserves::RevertWaitingStatus( |
965 |
C4::Reserves::RevertWaitingStatus( |
956 |
{ itemnumber => $item->itemnumber } ); |
966 |
{ itemnumber => $item->itemnumber } ); |
Lines 1428-1430
subtest 'AddReserve() tests' => sub {
Link Here
|
1428 |
|
1438 |
|
1429 |
$schema->storage->txn_rollback; |
1439 |
$schema->storage->txn_rollback; |
1430 |
}; |
1440 |
}; |
1431 |
- |
1441 |
|
|
|
1442 |
subtest 'AlterPriorty() tests' => sub { |
1443 |
|
1444 |
plan tests => 2; |
1445 |
|
1446 |
$schema->storage->txn_begin; |
1447 |
|
1448 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
1449 |
my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' }); |
1450 |
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); |
1451 |
my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' }); |
1452 |
my $biblio = $builder->build_sample_biblio; |
1453 |
|
1454 |
my $reserve_id = AddReserve( |
1455 |
{ |
1456 |
branchcode => $library->branchcode, |
1457 |
borrowernumber => $patron_1->id, |
1458 |
biblionumber => $biblio->id, |
1459 |
} |
1460 |
); |
1461 |
AddReserve( |
1462 |
{ |
1463 |
branchcode => $library->branchcode, |
1464 |
borrowernumber => $patron_2->id, |
1465 |
biblionumber => $biblio->id, |
1466 |
} |
1467 |
); |
1468 |
AddReserve( |
1469 |
{ |
1470 |
branchcode => $library->branchcode, |
1471 |
borrowernumber => $patron_3->id, |
1472 |
biblionumber => $biblio->id, |
1473 |
} |
1474 |
); |
1475 |
|
1476 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
1477 |
$mock->mock( 'enqueue', sub { |
1478 |
my ( $self, $args ) = @_; |
1479 |
is_deeply( |
1480 |
$args->{biblio_ids}, |
1481 |
[ $biblio->id ], |
1482 |
"AlterPriority triggers a holds queue update for the related biblio" |
1483 |
); |
1484 |
} ); |
1485 |
|
1486 |
|
1487 |
AlterPriority( "bottom", $reserve_id, 1, 2, 1, 3 ); |
1488 |
|
1489 |
my $hold = Koha::Holds->find($reserve_id); |
1490 |
|
1491 |
is($hold->priority,3,'Successfully altered priority to bottom'); |
1492 |
|
1493 |
$schema->storage->txn_rollback; |
1494 |
}; |