View | Details | Raw Unified | Return to bug 29483
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-38 / +128 lines)
Lines 1623-1638 subtest "Bug 13841 - Do not create new 0 amount fines" => sub { Link Here
1623
};
1623
};
1624
1624
1625
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
1625
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
1626
    $dbh->do('DELETE FROM issues');
1626
    plan tests => 9;
1627
    $dbh->do('DELETE FROM items');
1627
    my $biblio = $builder->build_sample_biblio();
1628
    $dbh->do('DELETE FROM circulation_rules');
1628
    my $item_1 = $builder->build_sample_item(
1629
        {
1630
            biblionumber     => $biblio->biblionumber,
1631
            library          => $library2->{branchcode},
1632
        }
1633
    );
1634
    my $item_2= $builder->build_sample_item(
1635
        {
1636
            biblionumber     => $biblio->biblionumber,
1637
            library          => $library2->{branchcode},
1638
            itype            => $item_1->effective_itemtype,
1639
        }
1640
    );
1641
1629
    Koha::CirculationRules->set_rules(
1642
    Koha::CirculationRules->set_rules(
1630
        {
1643
        {
1631
            categorycode => undef,
1644
            categorycode => undef,
1632
            itemtype     => undef,
1645
            itemtype     => $item_1->effective_itemtype,
1633
            branchcode   => undef,
1646
            branchcode   => undef,
1634
            rules        => {
1647
            rules        => {
1635
                reservesallowed => 25,
1648
                reservesallowed => 25,
1649
                holds_per_record => 25,
1636
                issuelength     => 14,
1650
                issuelength     => 14,
1637
                lengthunit      => 'days',
1651
                lengthunit      => 'days',
1638
                renewalsallowed => 1,
1652
                renewalsallowed => 1,
Lines 1645-1667 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1645
            }
1659
            }
1646
        }
1660
        }
1647
    );
1661
    );
1648
    my $biblio = $builder->build_sample_biblio();
1649
1662
1650
    my $item_1 = $builder->build_sample_item(
1651
        {
1652
            biblionumber     => $biblio->biblionumber,
1653
            library          => $library2->{branchcode},
1654
            itype            => $itemtype,
1655
        }
1656
    );
1657
1658
    my $item_2= $builder->build_sample_item(
1659
        {
1660
            biblionumber     => $biblio->biblionumber,
1661
            library          => $library2->{branchcode},
1662
            itype            => $itemtype,
1663
        }
1664
    );
1665
1663
1666
    my $borrowernumber1 = Koha::Patron->new({
1664
    my $borrowernumber1 = Koha::Patron->new({
1667
        firstname    => 'Kyle',
1665
        firstname    => 'Kyle',
Lines 1675-1680 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1675
        categorycode => $patron_category->{categorycode},
1673
        categorycode => $patron_category->{categorycode},
1676
        branchcode   => $library2->{branchcode},
1674
        branchcode   => $library2->{branchcode},
1677
    })->store->borrowernumber;
1675
    })->store->borrowernumber;
1676
    my $patron_category_2 = $builder->build(
1677
        {
1678
            source => 'Category',
1679
            value  => {
1680
                category_type                 => 'P',
1681
                enrolmentfee                  => 0,
1682
                BlockExpiredPatronOpacActions => -1, # Pick the pref value
1683
            }
1684
        }
1685
    );
1686
    my $borrowernumber3 = Koha::Patron->new({
1687
        firstname    => 'Carnegie',
1688
        surname      => 'Hall',
1689
        categorycode => $patron_category_2->{categorycode},
1690
        branchcode   => $library2->{branchcode},
1691
    })->store->borrowernumber;
1678
1692
1679
    my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed;
1693
    my $borrower1 = Koha::Patrons->find( $borrowernumber1 )->unblessed;
1680
    my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed;
1694
    my $borrower2 = Koha::Patrons->find( $borrowernumber2 )->unblessed;
Lines 1696-1702 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1696
    Koha::CirculationRules->set_rules(
1710
    Koha::CirculationRules->set_rules(
1697
        {
1711
        {
1698
            categorycode => undef,
1712
            categorycode => undef,
1699
            itemtype     => undef,
1713
            itemtype     => $item_1->effective_itemtype,
1700
            branchcode   => undef,
1714
            branchcode   => undef,
1701
            rules        => {
1715
            rules        => {
1702
                onshelfholds => 0,
1716
                onshelfholds => 0,
Lines 1707-1722 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1707
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1721
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1708
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );
1722
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );
1709
1723
1710
    Koha::CirculationRules->set_rules(
1711
        {
1712
            categorycode => undef,
1713
            itemtype     => undef,
1714
            branchcode   => undef,
1715
            rules        => {
1716
                onshelfholds => 0,
1717
            }
1718
        }
1719
    );
1720
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
1724
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
1721
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1725
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1722
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );
1726
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );
Lines 1724-1730 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1724
    Koha::CirculationRules->set_rules(
1728
    Koha::CirculationRules->set_rules(
1725
        {
1729
        {
1726
            categorycode => undef,
1730
            categorycode => undef,
1727
            itemtype     => undef,
1731
            itemtype     => $item_1->effective_itemtype,
1728
            branchcode   => undef,
1732
            branchcode   => undef,
1729
            rules        => {
1733
            rules        => {
1730
                onshelfholds => 1,
1734
                onshelfholds => 1,
Lines 1735-1759 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
1735
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1739
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1736
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );
1740
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );
1737
1741
1742
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
1743
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1744
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1745
1746
    AddReserve(
1747
        {
1748
            branchcode     => $library2->{branchcode},
1749
            borrowernumber => $borrowernumber3,
1750
            biblionumber   => $biblio->biblionumber,
1751
            priority       => 1,
1752
        }
1753
    );
1754
1755
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1756
    is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and one other item on record' );
1757
1758
    my $item_3= $builder->build_sample_item(
1759
        {
1760
            biblionumber     => $biblio->biblionumber,
1761
            library          => $library2->{branchcode},
1762
            itype            => $item_1->effective_itemtype,
1763
        }
1764
    );
1765
1766
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1767
    is( $renewokay, 1, 'Verify the borrower cannot renew with 2 holds on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );
1768
1738
    Koha::CirculationRules->set_rules(
1769
    Koha::CirculationRules->set_rules(
1739
        {
1770
        {
1740
            categorycode => undef,
1771
            categorycode => $patron_category_2->{categorycode},
1741
            itemtype     => undef,
1772
            itemtype     => $item_1->effective_itemtype,
1742
            branchcode   => undef,
1773
            branchcode   => undef,
1743
            rules        => {
1774
            rules        => {
1744
                onshelfholds => 1,
1775
                reservesallowed => 0,
1745
            }
1776
            }
1746
        }
1777
        }
1747
    );
1778
    );
1748
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
1779
1749
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1780
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1750
    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
1781
    is( $renewokay, 0, 'Verify the borrower cannot renew with 2 holds on the record, but only one of those holds can be filled when AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled and two other items on record' );
1751
1782
1752
    # Setting item not checked out to be not for loan but holdable
1783
    # Setting item not checked out to be not for loan but holdable
1753
    $item_2->notforloan(-1)->store;
1784
    $item_2->notforloan(-1)->store;
1754
1785
1755
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1786
    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
1756
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );
1787
    is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );
1788
1757
};
1789
};
1758
1790
1759
{
1791
{
Lines 1838-1843 subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { Link Here
1838
            holdingbranch => $holdingbranch->{branchcode},
1870
            holdingbranch => $holdingbranch->{branchcode},
1839
        }
1871
        }
1840
    );
1872
    );
1873
    Koha::CirculationRules->set_rules(
1874
        {
1875
            categorycode => undef,
1876
            itemtype     => $item->effective_itemtype,
1877
            branchcode   => undef,
1878
            rules        => {
1879
                reservesallowed => 25,
1880
                issuelength     => 14,
1881
                lengthunit      => 'days',
1882
                renewalsallowed => 1,
1883
                renewalperiod   => 7,
1884
                norenewalbefore => undef,
1885
                auto_renew      => 0,
1886
                fine            => .10,
1887
                chargeperiod    => 1,
1888
                maxissueqty     => 20
1889
            }
1890
        }
1891
    );
1841
1892
1842
    set_userenv($holdingbranch);
1893
    set_userenv($holdingbranch);
1843
1894
Lines 2053-2058 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2053
            library => $library->{branchcode},
2104
            library => $library->{branchcode},
2054
        }
2105
        }
2055
    );
2106
    );
2107
    Koha::CirculationRules->set_rules(
2108
        {
2109
            categorycode => undef,
2110
            itemtype     => undef,
2111
            branchcode   => $library->{branchcode},
2112
            rules        => {
2113
                reservesallowed => 25,
2114
                issuelength     => 14,
2115
                lengthunit      => 'days',
2116
                renewalsallowed => 1,
2117
                renewalperiod   => 7,
2118
                norenewalbefore => undef,
2119
                auto_renew      => 0,
2120
                fine            => .10,
2121
                chargeperiod    => 1,
2122
                maxissueqty     => 20
2123
            }
2124
        }
2125
    );
2126
2056
2127
2057
    my ( $error, $question, $alerts );
2128
    my ( $error, $question, $alerts );
2058
2129
Lines 2250-2255 subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { Link Here
2250
        }
2321
        }
2251
    );
2322
    );
2252
2323
2324
    Koha::CirculationRules->set_rules(
2325
        {
2326
            categorycode => undef,
2327
            itemtype     => undef,
2328
            branchcode   => $library->{branchcode},
2329
            rules        => {
2330
                reservesallowed => 25,
2331
                issuelength     => 14,
2332
                lengthunit      => 'days',
2333
                renewalsallowed => 1,
2334
                renewalperiod   => 7,
2335
                norenewalbefore => undef,
2336
                auto_renew      => 0,
2337
                fine            => .10,
2338
                chargeperiod    => 1,
2339
                maxissueqty     => 20
2340
            }
2341
        }
2342
    );
2343
2253
    my ( $error, $question, $alerts );
2344
    my ( $error, $question, $alerts );
2254
    my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) );
2345
    my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) );
2255
2346
2256
- 

Return to bug 29483