|
Lines 1639-1644
subtest 'can_be_transferred' => sub {
Link Here
|
| 1639 |
'We get the same result also if we pass the from-library parameter.'); |
1639 |
'We get the same result also if we pass the from-library parameter.'); |
| 1640 |
}; |
1640 |
}; |
| 1641 |
|
1641 |
|
|
|
1642 |
subtest 'filter_by_for_hold' => sub { |
| 1643 |
plan tests => 12; |
| 1644 |
|
| 1645 |
Koha::CirculationRules->search( |
| 1646 |
{ |
| 1647 |
rule_name => 'holdallowed', |
| 1648 |
rule_value => 'not_allowed', |
| 1649 |
} |
| 1650 |
)->delete; |
| 1651 |
|
| 1652 |
my $biblio = $builder->build_sample_biblio; |
| 1653 |
is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' ); |
| 1654 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); |
| 1655 |
is( $biblio->items->filter_by_for_hold->count, 0, 'no item for hold' ); |
| 1656 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } ); |
| 1657 |
is( $biblio->items->filter_by_for_hold->count, 1, '1 item for hold' ); |
| 1658 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } ); |
| 1659 |
is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' ); |
| 1660 |
|
| 1661 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 0 } ); |
| 1662 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1 } ); |
| 1663 |
is( $biblio->items->filter_by_for_hold->count, 3, '3 items for hold - itemlost' ); |
| 1664 |
|
| 1665 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 0 } ); |
| 1666 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1 } ); |
| 1667 |
is( $biblio->items->filter_by_for_hold->count, 4, '4 items for hold - withdrawn' ); |
| 1668 |
|
| 1669 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 0 } ); |
| 1670 |
$builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 1 } ); |
| 1671 |
t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 0); |
| 1672 |
is( $biblio->items->filter_by_for_hold->count, 5, '5 items for hold - not damaged if not AllowHoldsOnDamagedItems' ); |
| 1673 |
t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); |
| 1674 |
is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - damaged if AllowHoldsOnDamagedItems' ); |
| 1675 |
|
| 1676 |
my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); |
| 1677 |
my $not_holdable_itemtype = $itemtype->itemtype; |
| 1678 |
$builder->build_sample_item( |
| 1679 |
{ |
| 1680 |
biblionumber => $biblio->biblionumber, |
| 1681 |
itype => $not_holdable_itemtype, |
| 1682 |
} |
| 1683 |
); |
| 1684 |
Koha::CirculationRules->set_rule( |
| 1685 |
{ |
| 1686 |
branchcode => undef, |
| 1687 |
itemtype => $not_holdable_itemtype, |
| 1688 |
rule_name => 'holdallowed', |
| 1689 |
rule_value => 'not_allowed', |
| 1690 |
} |
| 1691 |
); |
| 1692 |
is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - holdallowed=not_allowed' ); |
| 1693 |
|
| 1694 |
# Remove rule, test notforloan on itemtype |
| 1695 |
Koha::CirculationRules->set_rule( |
| 1696 |
{ |
| 1697 |
branchcode => undef, |
| 1698 |
itemtype => $not_holdable_itemtype, |
| 1699 |
rule_name => 'holdallowed', |
| 1700 |
rule_value => undef, |
| 1701 |
} |
| 1702 |
); |
| 1703 |
is( $biblio->items->filter_by_for_hold->count, 7, '7 items for hold - rule deleted' ); |
| 1704 |
$itemtype->notforloan(1)->store; |
| 1705 |
is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - notforloan' ); |
| 1706 |
|
| 1707 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
| 1708 |
$biblio->biblioitem->itemtype($not_holdable_itemtype)->store; |
| 1709 |
is( $biblio->items->filter_by_for_hold->count, 0, '0 item-level_itypes=0' ); |
| 1710 |
|
| 1711 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
| 1712 |
|
| 1713 |
$biblio->delete; |
| 1714 |
}; |
| 1715 |
|
| 1642 |
# Reset nb_of_items prior to testing delete |
1716 |
# Reset nb_of_items prior to testing delete |
| 1643 |
$nb_of_items = Koha::Items->search->count; |
1717 |
$nb_of_items = Koha::Items->search->count; |
| 1644 |
|
1718 |
|
| 1645 |
- |
|
|