|
Lines 1264-1270
subtest 'strings_map() tests' => sub {
Link Here
|
| 1264 |
|
1264 |
|
| 1265 |
subtest 'revert_found() tests' => sub { |
1265 |
subtest 'revert_found() tests' => sub { |
| 1266 |
|
1266 |
|
| 1267 |
plan tests => 6; |
1267 |
plan tests => 7; |
| 1268 |
|
1268 |
|
| 1269 |
subtest 'item-level holds tests' => sub { |
1269 |
subtest 'item-level holds tests' => sub { |
| 1270 |
|
1270 |
|
|
Lines 1592-1597
subtest 'revert_found() tests' => sub {
Link Here
|
| 1592 |
$schema->storage->txn_rollback; |
1592 |
$schema->storage->txn_rollback; |
| 1593 |
}; |
1593 |
}; |
| 1594 |
|
1594 |
|
|
|
1595 |
subtest 'SIP do_hold/drop_hold regression: item-level visibility and cancel' => sub { |
| 1596 |
|
| 1597 |
plan tests => 6; |
| 1598 |
$schema->storage->txn_begin; |
| 1599 |
|
| 1600 |
use C4::Reserves qw(AddReserve); |
| 1601 |
use Test::MockModule; |
| 1602 |
|
| 1603 |
my $letters_mock = Test::MockModule->new('C4::Letters'); |
| 1604 |
$letters_mock->mock( 'GetPreparedLetter', sub { return { content => '', title => '' } } ); |
| 1605 |
|
| 1606 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1607 |
my $branch = $library->branchcode; |
| 1608 |
|
| 1609 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1610 |
|
| 1611 |
my $biblio = $builder->build_sample_biblio( { title => 'SIP regression test' } ); |
| 1612 |
my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
| 1613 |
my $priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); |
| 1614 |
AddReserve( |
| 1615 |
{ |
| 1616 |
branchcode => $branch, |
| 1617 |
borrowernumber => $patron->borrowernumber, |
| 1618 |
biblionumber => $biblio->biblionumber, |
| 1619 |
priority => $priority, |
| 1620 |
} |
| 1621 |
); |
| 1622 |
|
| 1623 |
my $holds_via_item_title = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); |
| 1624 |
is( |
| 1625 |
$holds_via_item_title->count, 0, |
| 1626 |
'Title-level hold is NOT visible via item->holds (expected baseline)' |
| 1627 |
); |
| 1628 |
|
| 1629 |
my $title_hold = Koha::Holds->search( |
| 1630 |
{ borrowernumber => $patron->borrowernumber, biblionumber => $biblio->biblionumber, itemnumber => undef } ) |
| 1631 |
->next; |
| 1632 |
ok( $title_hold, 'Title-level hold created' ); |
| 1633 |
|
| 1634 |
if ( $title_hold->can('cancel') ) { |
| 1635 |
$title_hold->cancel( { cancellation_reason => 'TEST' } ); |
| 1636 |
} else { |
| 1637 |
$title_hold->delete; |
| 1638 |
} |
| 1639 |
ok( !Koha::Holds->find( $title_hold->id ), 'Title-level hold canceled (cleanup)' ); |
| 1640 |
|
| 1641 |
$priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); |
| 1642 |
AddReserve( |
| 1643 |
{ |
| 1644 |
branchcode => $branch, |
| 1645 |
borrowernumber => $patron->borrowernumber, |
| 1646 |
biblionumber => $biblio->biblionumber, |
| 1647 |
itemnumber => $item->itemnumber, |
| 1648 |
priority => $priority, |
| 1649 |
} |
| 1650 |
); |
| 1651 |
|
| 1652 |
my $holds_via_item = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); |
| 1653 |
is( |
| 1654 |
$holds_via_item->count, 1, |
| 1655 |
'Item-level hold IS visible via item->holds (SIP drop_hold depends on this)' |
| 1656 |
); |
| 1657 |
my $item_hold = $holds_via_item->next; |
| 1658 |
ok( $item_hold && $item_hold->id, 'Have the specific item-level hold object' ); |
| 1659 |
if ( $item_hold->can('cancel') ) { |
| 1660 |
$item_hold->cancel( { cancellation_reason => 'TEST' } ); |
| 1661 |
} else { |
| 1662 |
$item_hold->delete; |
| 1663 |
} |
| 1664 |
ok( |
| 1665 |
!Koha::Holds->find( $item_hold->id ), |
| 1666 |
'Item-level hold canceled successfully (mirrors SIP drop_hold behavior)' |
| 1667 |
); |
| 1668 |
|
| 1669 |
$letters_mock->unmock_all; |
| 1670 |
|
| 1671 |
$schema->storage->txn_rollback; |
| 1672 |
}; |
| 1673 |
|
| 1595 |
subtest 'desk_id handling tests' => sub { |
1674 |
subtest 'desk_id handling tests' => sub { |
| 1596 |
|
1675 |
|
| 1597 |
plan tests => 12; |
1676 |
plan tests => 12; |
| 1598 |
- |
|
|