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

(-)a/t/db_dependent/Circulation.t (-4 / +57 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 102;
20
use Test::More tests => 103;
21
21
22
use DateTime;
22
use DateTime;
23
23
Lines 1780-1785 subtest 'Set waiting flag' => sub { Link Here
1780
1780
1781
    my $biblio = $builder->build( { source => 'Biblio' } );
1781
    my $biblio = $builder->build( { source => 'Biblio' } );
1782
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
1782
    my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } );
1783
1783
    my $item = $builder->build(
1784
    my $item = $builder->build(
1784
        {
1785
        {
1785
            source => 'Item',
1786
            source => 'Item',
Lines 1794-1801 subtest 'Set waiting flag' => sub { Link Here
1794
        }
1795
        }
1795
    );
1796
    );
1796
1797
1797
1798
1799
    set_userenv( $library_2 );
1798
    set_userenv( $library_2 );
1800
    my $reserve_id = AddReserve(
1799
    my $reserve_id = AddReserve(
1801
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
1800
        $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber},
Lines 1822-1827 subtest 'Set waiting flag' => sub { Link Here
1822
    is( $status, 'Waiting', 'Now the hold is waiting');
1821
    is( $status, 'Waiting', 'Now the hold is waiting');
1823
};
1822
};
1824
1823
1824
subtest 'AddReturn | is_overdue' => sub {
1825
    plan tests => 3;
1826
1827
    # Set a simple circ policy
1828
    $dbh->do('DELETE FROM issuingrules');
1829
    $dbh->do(
1830
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
1831
                                    maxissueqty, issuelength, lengthunit,
1832
                                    renewalsallowed, renewalperiod,
1833
                                    norenewalbefore, auto_renew,
1834
                                    fine, chargeperiod)
1835
          VALUES (?, ?, ?, ?,
1836
                  ?, ?, ?,
1837
                  ?, ?,
1838
                  ?, ?,
1839
                  ?, ?
1840
                 )
1841
        },
1842
        {},
1843
        '*',   '*', '*', 25,
1844
        1,     14,  'days',
1845
        1,     7,
1846
        undef, 0,
1847
        .10,   1
1848
    );
1849
1850
    my $five_days_go = output_pref({ dt => dt_from_string->add( days => 5 ), dateonly => 1});
1851
    my $ten_days_go  = output_pref({ dt => dt_from_string->add( days => 10), dateonly => 1 });
1852
    my $library = $builder->build( { source => 'Branch' } );
1853
    my $patron  = $builder->build( { source => 'Borrower' } );
1854
1855
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
1856
    my $item = $builder->build(
1857
        {
1858
            source => 'Item',
1859
            value  => {
1860
                homebranch    => $library->{branchcode},
1861
                holdingbranch => $library->{branchcode},
1862
                notforloan    => 0,
1863
                itemlost      => 0,
1864
                withdrawn     => 0,
1865
                biblionumber  => $biblioitem->{biblionumber},
1866
            }
1867
        }
1868
    );
1869
1870
    my $issue = AddIssue( $patron, $item->{barcode}, $five_days_go ); # date due was 10d ago
1871
    my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } );
1872
    is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works");
1873
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef);
1874
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
1875
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
1876
1877
};
1878
1825
sub set_userenv {
1879
sub set_userenv {
1826
    my ( $library ) = @_;
1880
    my ( $library ) = @_;
1827
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', '');
1881
    C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', '');
1828
- 

Return to bug 19198