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

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

Return to bug 19198