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

(-)a/t/db_dependent/Fines.t (-5 / +6 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use DateTime;
4
5
5
use C4::Context;
6
use C4::Context;
6
use C4::Overdues;
7
use C4::Overdues;
Lines 34-56 my $issuingrule = $schema->resultset('Issuingrule')->create( Link Here
34
35
35
ok( $issuingrule, 'Issuing rule created' );
36
ok( $issuingrule, 'Issuing rule created' );
36
37
37
my $period_start = dt_from_string('2000-01-01');
38
my $period_start = DateTime->today;
38
my $period_end = dt_from_string('2000-01-05');
39
my $period_end = DateTime->today->add(days => 4);
39
40
40
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
41
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
41
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
42
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
42
43
43
$period_end = dt_from_string('2000-01-10');
44
$period_end = DateTime->today->add(days => 9);
44
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
45
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
45
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
46
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
46
47
47
# Test charging fine at the *beginning* of each charge period
48
# Test charging fine at the *beginning* of each charge period
48
$issuingrule->update( { chargeperiod_charge_at => 1 } );
49
$issuingrule->update( { chargeperiod_charge_at => 1 } );
49
50
50
$period_end = dt_from_string('2000-01-05');
51
$period_end = DateTime->today->add(days => 4);
51
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
52
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
52
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
53
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
53
54
54
$period_end = dt_from_string('2000-01-10');
55
$period_end = DateTime->today->add(days => 9);
55
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
56
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
56
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
57
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );
(-)a/t/db_dependent/Holds.t (-11 / +5 lines)
Lines 13-18 use C4::Biblio; Link Here
13
use C4::Items;
13
use C4::Items;
14
use C4::Members;
14
use C4::Members;
15
use C4::Calendar;
15
use C4::Calendar;
16
use Koha::DiscreteCalendar;
16
use Koha::Database;
17
use Koha::Database;
17
use Koha::DateUtils qw( dt_from_string output_pref );
18
use Koha::DateUtils qw( dt_from_string output_pref );
18
use Koha::Holds;
19
use Koha::Holds;
Lines 426-444 is(CanItemBeReserved($borrowernumbers[0], $itemnumber), 'OK', Link Here
426
t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelay', 1);
427
t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelay', 1);
427
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 1);
428
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 1);
428
429
429
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time);
430
$year += 1900;
431
$mon += 1;
432
$reserves = $dbh->selectall_arrayref('SELECT * FROM reserves', { Slice => {} });
430
$reserves = $dbh->selectall_arrayref('SELECT * FROM reserves', { Slice => {} });
433
$reserve = $reserves->[0];
431
$reserve = $reserves->[0];
434
my $calendar = C4::Calendar->new(branchcode => $reserve->{branchcode});
432
435
$calendar->insert_single_holiday(
433
my $today = dt_from_string();
436
    day         => $mday,
434
Koha::DiscreteCalendar->new( branchcode => $reserve->{branchcode} )->edit_holiday("Today", '', "E", '', '', $today, $today);
437
    month       => $mon,
435
438
    year        => $year,
439
    title       => 'Test',
440
    description => 'Test',
441
);
442
$reserve_id = $reserve->{reserve_id};
436
$reserve_id = $reserve->{reserve_id};
443
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id );
437
$dbh->do("UPDATE reserves SET waitingdate = DATE_SUB( NOW(), INTERVAL 5 DAY ), found = 'W', priority = 0 WHERE reserve_id = ?", undef, $reserve_id );
444
t::lib::Mocks::mock_preference('ExpireReservesOnHolidays', 0);
438
t::lib::Mocks::mock_preference('ExpireReservesOnHolidays', 0);
(-)a/t/db_dependent/HoldsQueue.t (-10 / +6 lines)
Lines 11-19 use Modern::Perl; Link Here
11
use Test::More tests => 42;
11
use Test::More tests => 42;
12
use Data::Dumper;
12
use Data::Dumper;
13
13
14
use C4::Calendar;
15
use C4::Context;
14
use C4::Context;
16
use C4::Members;
15
use C4::Members;
16
use Koha::DiscreteCalendar;
17
use Koha::Database;
17
use Koha::Database;
18
use Koha::DateUtils;
18
use Koha::DateUtils;
19
19
Lines 181-192 $itemtype = $builder->build({ source => 'Itemtype', value => { notforloan => 0 } Link Here
181
$library1 = $builder->build({
181
$library1 = $builder->build({
182
    source => 'Branch',
182
    source => 'Branch',
183
});
183
});
184
$library1->{branchcode} = 'CPL';
184
$library2 = $builder->build({
185
$library2 = $builder->build({
185
    source => 'Branch',
186
    source => 'Branch',
186
});
187
});
188
$library2->{branchcode} ='FFL';
187
$library3 = $builder->build({
189
$library3 = $builder->build({
188
    source => 'Branch',
190
    source => 'Branch',
189
});
191
});
192
$library3->{branchcode} ='LPL';
190
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
193
@branchcodes = ( $library1->{branchcode}, $library2->{branchcode}, $library3->{branchcode} );
191
194
192
my $borrower1 = $builder->build({
195
my $borrower1 = $builder->build({
Lines 300-315 is( $holds_queue->[1]->{cardnumber}, $borrower2->{cardnumber}, "Holds queue fill Link Here
300
# have 1 row in the holds queue
303
# have 1 row in the holds queue
301
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
304
t::lib::Mocks::mock_preference('HoldsQueueSkipClosed', 1);
302
my $today = dt_from_string();
305
my $today = dt_from_string();
303
C4::Calendar->new( branchcode => $branchcodes[0] )->insert_single_holiday(
304
    day         => $today->day(),
305
    month       => $today->month(),
306
    year        => $today->year(),
307
    title       => "$today",
308
    description => "$today",
309
);
310
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
306
# If the test below is removed, aother tests using the holiday will fail. For some reason if we call is_holiday now
311
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
307
# the holiday will get set in cache correctly, but not if we let C4::HoldsQueue call is_holiday instead.
312
is( Koha::Calendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
308
Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->edit_holiday("Today", '', "E", '', '', $today, $today);
309
is( Koha::DiscreteCalendar->new( branchcode => $branchcodes[0] )->is_holiday( $today ), 1, 'Is today a holiday for pickup branch' );
313
C4::HoldsQueue::CreateQueue();
310
C4::HoldsQueue::CreateQueue();
314
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
311
$holds_queue = $dbh->selectall_arrayref("SELECT * FROM tmp_holdsqueue", { Slice => {} });
315
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
312
is( scalar( @$holds_queue ), 1, "Holds not filled with items from closed libraries" );
316
- 

Return to bug 17015