|
Lines 1301-1307
subtest 'strings_map() tests' => sub {
Link Here
|
| 1301 |
|
1301 |
|
| 1302 |
subtest 'revert_found() tests' => sub { |
1302 |
subtest 'revert_found() tests' => sub { |
| 1303 |
|
1303 |
|
| 1304 |
plan tests => 6; |
1304 |
plan tests => 7; |
| 1305 |
|
1305 |
|
| 1306 |
subtest 'item-level holds tests' => sub { |
1306 |
subtest 'item-level holds tests' => sub { |
| 1307 |
|
1307 |
|
|
Lines 1629-1634
subtest 'revert_found() tests' => sub {
Link Here
|
| 1629 |
$schema->storage->txn_rollback; |
1629 |
$schema->storage->txn_rollback; |
| 1630 |
}; |
1630 |
}; |
| 1631 |
|
1631 |
|
|
|
1632 |
subtest 'SIP do_hold/drop_hold regression: item-level visibility and cancel' => sub { |
| 1633 |
|
| 1634 |
plan tests => 6; |
| 1635 |
$schema->storage->txn_begin; |
| 1636 |
|
| 1637 |
use C4::Reserves qw(AddReserve); |
| 1638 |
use Test::MockModule; |
| 1639 |
|
| 1640 |
my $letters_mock = Test::MockModule->new('C4::Letters'); |
| 1641 |
$letters_mock->mock( 'GetPreparedLetter', sub { return { content => '', title => '' } } ); |
| 1642 |
|
| 1643 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1644 |
my $branch = $library->branchcode; |
| 1645 |
|
| 1646 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1647 |
|
| 1648 |
my $biblio = $builder->build_sample_biblio( { title => 'SIP regression test' } ); |
| 1649 |
my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
| 1650 |
my $priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); |
| 1651 |
AddReserve( |
| 1652 |
{ |
| 1653 |
branchcode => $branch, |
| 1654 |
borrowernumber => $patron->borrowernumber, |
| 1655 |
biblionumber => $biblio->biblionumber, |
| 1656 |
priority => $priority, |
| 1657 |
} |
| 1658 |
); |
| 1659 |
|
| 1660 |
my $holds_via_item_title = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); |
| 1661 |
is( |
| 1662 |
$holds_via_item_title->count, 0, |
| 1663 |
'Title-level hold is NOT visible via item->holds (expected baseline)' |
| 1664 |
); |
| 1665 |
|
| 1666 |
my $title_hold = Koha::Holds->search( |
| 1667 |
{ borrowernumber => $patron->borrowernumber, biblionumber => $biblio->biblionumber, itemnumber => undef } ) |
| 1668 |
->next; |
| 1669 |
ok( $title_hold, 'Title-level hold created' ); |
| 1670 |
|
| 1671 |
if ( $title_hold->can('cancel') ) { |
| 1672 |
$title_hold->cancel( { cancellation_reason => 'TEST' } ); |
| 1673 |
} else { |
| 1674 |
$title_hold->delete; |
| 1675 |
} |
| 1676 |
ok( !Koha::Holds->find( $title_hold->id ), 'Title-level hold canceled (cleanup)' ); |
| 1677 |
|
| 1678 |
$priority = C4::Reserves::CalculatePriority( $biblio->biblionumber ); |
| 1679 |
AddReserve( |
| 1680 |
{ |
| 1681 |
branchcode => $branch, |
| 1682 |
borrowernumber => $patron->borrowernumber, |
| 1683 |
biblionumber => $biblio->biblionumber, |
| 1684 |
itemnumber => $item->itemnumber, |
| 1685 |
priority => $priority, |
| 1686 |
} |
| 1687 |
); |
| 1688 |
|
| 1689 |
my $holds_via_item = $item->holds->search( { borrowernumber => $patron->borrowernumber } ); |
| 1690 |
is( |
| 1691 |
$holds_via_item->count, 1, |
| 1692 |
'Item-level hold IS visible via item->holds (SIP drop_hold depends on this)' |
| 1693 |
); |
| 1694 |
my $item_hold = $holds_via_item->next; |
| 1695 |
ok( $item_hold && $item_hold->id, 'Have the specific item-level hold object' ); |
| 1696 |
if ( $item_hold->can('cancel') ) { |
| 1697 |
$item_hold->cancel( { cancellation_reason => 'TEST' } ); |
| 1698 |
} else { |
| 1699 |
$item_hold->delete; |
| 1700 |
} |
| 1701 |
ok( |
| 1702 |
!Koha::Holds->find( $item_hold->id ), |
| 1703 |
'Item-level hold canceled successfully (mirrors SIP drop_hold behavior)' |
| 1704 |
); |
| 1705 |
|
| 1706 |
$letters_mock->unmock_all; |
| 1707 |
|
| 1708 |
$schema->storage->txn_rollback; |
| 1709 |
}; |
| 1710 |
|
| 1632 |
subtest 'desk_id handling tests' => sub { |
1711 |
subtest 'desk_id handling tests' => sub { |
| 1633 |
|
1712 |
|
| 1634 |
plan tests => 12; |
1713 |
plan tests => 12; |
| 1635 |
- |
|
|