|
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 => 5; |
1267 |
plan tests => 6; |
| 1268 |
|
1268 |
|
| 1269 |
subtest 'item-level holds tests' => sub { |
1269 |
subtest 'item-level holds tests' => sub { |
| 1270 |
|
1270 |
|
|
Lines 1591-1594
subtest 'revert_found() tests' => sub {
Link Here
|
| 1591 |
|
1591 |
|
| 1592 |
$schema->storage->txn_rollback; |
1592 |
$schema->storage->txn_rollback; |
| 1593 |
}; |
1593 |
}; |
|
|
1594 |
|
| 1595 |
subtest 'desk_id handling tests' => sub { |
| 1596 |
|
| 1597 |
plan tests => 12; |
| 1598 |
|
| 1599 |
$schema->storage->txn_begin; |
| 1600 |
|
| 1601 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1602 |
my $desk = $builder->build_object( |
| 1603 |
{ |
| 1604 |
class => 'Koha::Desks', |
| 1605 |
value => { branchcode => $library->branchcode } |
| 1606 |
} |
| 1607 |
); |
| 1608 |
my $patron = $builder->build_object( |
| 1609 |
{ |
| 1610 |
class => 'Koha::Patrons', |
| 1611 |
value => { branchcode => $library->branchcode } |
| 1612 |
} |
| 1613 |
); |
| 1614 |
my $item = $builder->build_sample_item( { library => $library->branchcode } ); |
| 1615 |
|
| 1616 |
my $hold = $builder->build_object( |
| 1617 |
{ |
| 1618 |
class => 'Koha::Holds', |
| 1619 |
value => { |
| 1620 |
borrowernumber => $patron->borrowernumber, |
| 1621 |
biblionumber => $item->biblionumber, |
| 1622 |
itemnumber => $item->itemnumber, |
| 1623 |
branchcode => $library->branchcode, |
| 1624 |
priority => 1, |
| 1625 |
found => undef, |
| 1626 |
} |
| 1627 |
} |
| 1628 |
); |
| 1629 |
|
| 1630 |
# Test 1: Waiting hold - desk_id should be cleared |
| 1631 |
$hold->set_waiting( $desk->desk_id ); |
| 1632 |
$hold->discard_changes; |
| 1633 |
is( $hold->desk_id, $desk->desk_id, 'desk_id set for waiting hold' ); |
| 1634 |
ok( $hold->is_waiting, 'Hold is in waiting status' ); |
| 1635 |
|
| 1636 |
$hold->revert_found(); |
| 1637 |
$hold->discard_changes; |
| 1638 |
is( $hold->desk_id, undef, 'desk_id cleared when reverting waiting hold' ); |
| 1639 |
ok( !$hold->is_found, 'Hold is no longer in found status' ); |
| 1640 |
|
| 1641 |
# Test 2: In transit hold with desk_id - desk_id should be preserved |
| 1642 |
$hold->set_transfer(); |
| 1643 |
$hold->desk_id( $desk->desk_id )->store(); # Manually set desk_id |
| 1644 |
$hold->discard_changes; |
| 1645 |
is( $hold->desk_id, $desk->desk_id, 'desk_id manually set for transit hold' ); |
| 1646 |
ok( $hold->is_in_transit, 'Hold is in transit status' ); |
| 1647 |
|
| 1648 |
$hold->revert_found(); |
| 1649 |
$hold->discard_changes; |
| 1650 |
is( $hold->desk_id, $desk->desk_id, 'desk_id preserved when reverting transit hold' ); |
| 1651 |
|
| 1652 |
# Test 3: In processing hold with desk_id - desk_id should be preserved |
| 1653 |
$hold->set_processing(); |
| 1654 |
$hold->desk_id( $desk->desk_id )->store(); # Manually set desk_id |
| 1655 |
$hold->discard_changes; |
| 1656 |
is( $hold->desk_id, $desk->desk_id, 'desk_id manually set for processing hold' ); |
| 1657 |
ok( $hold->is_in_processing, 'Hold is in processing status' ); |
| 1658 |
|
| 1659 |
$hold->revert_found(); |
| 1660 |
$hold->discard_changes; |
| 1661 |
is( $hold->desk_id, $desk->desk_id, 'desk_id preserved when reverting processing hold' ); |
| 1662 |
|
| 1663 |
# Test 4: In transit hold without desk_id - desk_id should remain NULL |
| 1664 |
$hold->set_transfer(); |
| 1665 |
$hold->desk_id(undef)->store(); # Ensure desk_id is NULL |
| 1666 |
$hold->discard_changes; |
| 1667 |
is( $hold->desk_id, undef, 'desk_id is NULL for transit hold without desk_id' ); |
| 1668 |
|
| 1669 |
$hold->revert_found(); |
| 1670 |
$hold->discard_changes; |
| 1671 |
is( $hold->desk_id, undef, 'desk_id remains NULL after reverting transit hold without desk_id' ); |
| 1672 |
|
| 1673 |
$schema->storage->txn_rollback; |
| 1674 |
}; |
| 1594 |
}; |
1675 |
}; |
| 1595 |
- |
|
|