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

(-)a/Koha/Patron/Category.pm (+1 lines)
Lines 182-187 sub get_expiry_date { Link Here
182
    my ($self, $date ) = @_;
182
    my ($self, $date ) = @_;
183
    if ( $self->enrolmentperiod ) {
183
    if ( $self->enrolmentperiod ) {
184
        $date ||= dt_from_string;
184
        $date ||= dt_from_string;
185
        $date = dt_from_string( $date ) unless ref $date;
185
        return $date->add( months => $self->enrolmentperiod );
186
        return $date->add( months => $self->enrolmentperiod );
186
    } else {
187
    } else {
187
        return $self->enrolmentperioddate;
188
        return $self->enrolmentperioddate;
(-)a/t/db_dependent/Koha/Patron/Categories.t (-2 / +5 lines)
Lines 51-57 is_deeply( $retrieved_category_1->branch_limitations, [ $branch->{branchcode} ], Link Here
51
is_deeply( $retrieved_category_1->default_messaging, [], 'By default there is not messaging option' );
51
is_deeply( $retrieved_category_1->default_messaging, [], 'By default there is not messaging option' );
52
52
53
subtest 'get_expiry_date' => sub {
53
subtest 'get_expiry_date' => sub {
54
    plan tests => 4;
54
    plan tests => 5;
55
    my $next_month = dt_from_string->add( months => 1 );
55
    my $next_month = dt_from_string->add( months => 1 );
56
    my $next_year = dt_from_string->add( months => 12 );
56
    my $next_year = dt_from_string->add( months => 12 );
57
    my $yesterday = dt_from_string->add( days => -1 );
57
    my $yesterday = dt_from_string->add( days => -1 );
Lines 68-73 subtest 'get_expiry_date' => sub { Link Here
68
    $category->enrolmentperiod( 12 )->store;
68
    $category->enrolmentperiod( 12 )->store;
69
    is( $category->get_expiry_date, $next_year, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
69
    is( $category->get_expiry_date, $next_year, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
70
    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' );
70
    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' );
71
72
    my $hardcoded_date = '2000-01-31';
73
    is( $category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 ), 'get_expiry_date accepts strings as well'  );
74
71
    $category->delete;
75
    $category->delete;
72
};
76
};
73
77
74
- 

Return to bug 16911