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

(-)a/t/db_dependent/Calendar.t (-2 / +42 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 4;
20
use Test::More tests => 5;
21
use Time::Fake;
21
use Time::Fake;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
23
Lines 289-294 subtest 'hours_between | days_between' => sub { Link Here
289
289
290
    };
290
    };
291
291
292
    Time::Fake->reset;
293
};
294
295
subtest 'is_holiday' => sub {
296
    plan tests => 1;
297
298
    subtest 'weekday holidays' => sub {
299
        plan tests => 7;
300
301
        my $library = $builder->build_object( { class => 'Koha::Libraries' } );
302
303
        my $day = DateTime->now();
304
        my $dow = scalar $day->day_of_week;
305
        $dow = 0 if $dow == 7;
306
307
        # Closed this day of the week
308
        my $dbh = C4::Context->dbh;
309
        $dbh->do(
310
            q|
311
            INSERT INTO repeatable_holidays (branchcode,weekday,day,month,title,description)
312
            VALUES ( ?, ?, NULL, NULL, ?, '' )
313
        |, undef, $library->branchcode, $dow, "TEST"
314
        );
315
316
        # Iterate 7 days
317
        my $sth = $dbh->prepare(
318
"UPDATE repeatable_holidays SET weekday = ? WHERE branchcode = ? AND title = 'TEST'"
319
        );
320
        for my $i ( 0 .. 6 ) {
321
            my $calendar =
322
              Koha::Calendar->new( branchcode => $library->branchcode );
323
324
            is( $calendar->is_holiday($day), 1, $day->day_name() ." works as a repeatable holiday");
325
326
            # Increment the date and holiday day
327
            $day->add( days => 1 );
328
            $dow++;
329
            $dow = 0 if $dow == 7;
330
            $sth->execute($dow, $library->branchcode);
331
        }
332
    };
292
};
333
};
293
334
294
$schema->storage->txn_rollback();
335
$schema->storage->txn_rollback();
295
- 

Return to bug 25850