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

(-)a/Koha/Patron/Category.pm (+1 lines)
Lines 189-194 sub get_expiry_date { Link Here
189
    my ($self, $date ) = @_;
189
    my ($self, $date ) = @_;
190
    if ( $self->enrolmentperiod ) {
190
    if ( $self->enrolmentperiod ) {
191
        $date ||= dt_from_string;
191
        $date ||= dt_from_string;
192
        $date = dt_from_string( $date ) unless ref $date;
192
        return $date->add( months => $self->enrolmentperiod );
193
        return $date->add( months => $self->enrolmentperiod );
193
    } else {
194
    } else {
194
        return $self->enrolmentperioddate;
195
        return $self->enrolmentperioddate;
(-)a/t/db_dependent/Koha/Patron/Categories.t (-2 / +5 lines)
Lines 56-62 is( $retrieved_category_1->checkprevcheckout, 'inherit', 'Koha::Patron::Category Link Here
56
is( $retrieved_category_2->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
56
is( $retrieved_category_2->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
57
57
58
subtest 'get_expiry_date' => sub {
58
subtest 'get_expiry_date' => sub {
59
    plan tests => 4;
59
    plan tests => 5;
60
    my $next_month = dt_from_string->add( months => 1 );
60
    my $next_month = dt_from_string->add( months => 1 );
61
    my $next_year = dt_from_string->add( months => 12 );
61
    my $next_year = dt_from_string->add( months => 12 );
62
    my $yesterday = dt_from_string->add( days => -1 );
62
    my $yesterday = dt_from_string->add( days => -1 );
Lines 73-78 subtest 'get_expiry_date' => sub { Link Here
73
    $category->enrolmentperiod( 12 )->store;
73
    $category->enrolmentperiod( 12 )->store;
74
    is( $category->get_expiry_date, $next_year, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
74
    is( $category->get_expiry_date, $next_year, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
75
    is( $category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 ), 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
75
    is( $category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 ), 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
76
77
    my $hardcoded_date = '2000-01-31';
78
    is( $category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 ), 'get_expiry_date accepts strings as well'  );
79
76
    $category->delete;
80
    $category->delete;
77
};
81
};
78
82
79
- 

Return to bug 16911