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

(-)a/t/db_dependent/Calendar.t (-1 / +57 lines)
Lines 19-24 use Modern::Perl; Link Here
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 5;
21
use Time::Fake;
21
use Time::Fake;
22
23
use t::lib::Mocks;
22
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
23
25
24
use DateTime;
26
use DateTime;
Lines 332-335 subtest 'is_holiday' => sub { Link Here
332
    };
334
    };
333
};
335
};
334
336
337
subtest 'get_push_amt' => sub {
338
    plan tests => 1;
339
340
    t::lib::Mocks::mock_preference('useDaysMode', 'Dayweek');
341
342
    subtest 'weekday holidays' => sub {
343
        plan tests => 7;
344
345
        my $library = $builder->build_object( { class => 'Koha::Libraries' } );
346
347
        my $day = DateTime->now();
348
        my $dow = scalar $day->day_of_week;
349
        $dow = 0 if $dow == 7;
350
351
        # Closed this day of the week
352
        my $dbh = C4::Context->dbh;
353
        $dbh->do(
354
            q|
355
            INSERT INTO repeatable_holidays (branchcode,weekday,day,month,title,description)
356
            VALUES ( ?, ?, NULL, NULL, ?, '' )
357
        |, undef, $library->branchcode, $dow, "TEST"
358
        );
359
360
        # Iterate 7 days
361
        my $sth = $dbh->prepare(
362
"UPDATE repeatable_holidays SET weekday = ? WHERE branchcode = ? AND title = 'TEST'"
363
        );
364
        for my $i ( 0 .. 6 ) {
365
            my $calendar =
366
              Koha::Calendar->new( branchcode => $library->branchcode, days_mode => 'DayWeek' );
367
             
368
            my $npa;
369
            eval {
370
                local $SIG{ALRM} = sub { die "alarm\n" };    # NB: \n required
371
                alarm 2;
372
                $npa = $calendar->get_push_amt( $day, 1 );
373
                alarm 0;
374
            };
375
            if ($@) {
376
                die unless $@ eq "alarm\n";    # propagate unexpected errors
377
                                               # timed out
378
            }
379
            else {
380
                is($npa, 1, "next_push_amt succeeded for ".$day->day_name()." weekday holiday");
381
            }
382
383
            # Increment the date and holiday day
384
            $day->add( days => 1 );
385
            $dow++;
386
            $dow = 0 if $dow == 7;
387
            $sth->execute( $dow, $library->branchcode );
388
        }
389
    };
390
};
391
335
$schema->storage->txn_rollback();
392
$schema->storage->txn_rollback();
336
- 

Return to bug 25850