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

(-)a/t/db_dependent/Koha/Patron/Categories.t (-8 / +47 lines)
Lines 62-77 is( $retrieved_category_1->checkprevcheckout, 'inherit', 'Koha::Patron::Category Link Here
62
is( $retrieved_category_2->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
62
is( $retrieved_category_2->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
63
63
64
subtest 'get_expiry_date' => sub {
64
subtest 'get_expiry_date' => sub {
65
    plan tests => 5;
65
    plan tests => 3;
66
    for my $date ( '2016-03-31', '2016-11-30', '2019-01-31', '2019-03-01', dt_from_string() ) {
66
    my $cases = [
67
        subtest "get_expiry_date with today=$date" => sub {
67
        {
68
            today => '2016-03-31',
69
            next_month => '2016-04-30',
70
            next_year => '2017-03-31',
71
            yesterday => '2016-03-30',
72
        },
73
        {
74
            today => '2016-11-30',
75
            next_month => '2016-12-31',
76
            next_year => '2017-11-30',
77
            yesterday => '2016-11-29',
78
        },
79
        {
80
            today => '2019-01-31',
81
            next_month => '2019-02-28',
82
            next_year => '2020-01-31',
83
            yesterday => '2019-01-30',
84
        },
85
        {
86
            today => '2019-02-28',
87
            next_month => '2019-03-31',
88
            next_year => '2020-02-29',
89
            yesterday => '2019-02-27',
90
        },
91
        {
92
            today => '2019-03-01',
93
            next_month => '2019-02-28',
94
            next_year => '2020-03-01',
95
            yesterday => '2019-02-28',
96
        },
97
        {
98
            today => '2020-02-29',
99
            next_month => '2021-03-31',
100
            next_year => '2021-02-28',
101
            yesterday => '2020-02-28',
102
        },
103
        # TODO re-add today, dt_from_string
104
    ];
105
    for my $date ( @$cases ) {
106
        my $today = $date->{today};
107
        subtest "get_expiry_date with today=$today" => sub {
68
            plan tests => 5;
108
            plan tests => 5;
69
            my $dt = dt_from_string( $date, 'iso' );
109
            my $dt = dt_from_string( $today, 'iso' );
70
            Time::Fake->offset( $dt->epoch );
110
            Time::Fake->offset( $dt->epoch );
71
111
72
            my $next_month = dt_from_string->add( months => 1 );
112
            my $next_month = dt_from_string($date->{next_month}, 'iso');
73
            my $next_year = dt_from_string->add( months => 12 );
113
            my $next_year = dt_from_string($date->{next_year}, 'iso');
74
            my $yesterday = dt_from_string->add( days => -1 );
114
            my $yesterday = dt_from_string($date->{yesterday}, 'iso');
75
            my $category = Koha::Patron::Category->new({
115
            my $category = Koha::Patron::Category->new({
76
                categorycode => 'mycat',
116
                categorycode => 'mycat',
77
                category_type => 'A',
117
                category_type => 'A',
78
- 

Return to bug 22446