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

(-)a/t/db_dependent/Koha/Patron/Categories.t (-2 / +11 lines)
Lines 62-68 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 => 7;
66
    my $next_month = dt_from_string->add( months => 1 );
66
    my $next_month = dt_from_string->add( months => 1 );
67
    my $next_year = dt_from_string->add( months => 12 );
67
    my $next_year = dt_from_string->add( months => 12 );
68
    my $yesterday = dt_from_string->add( days => -1 );
68
    my $yesterday = dt_from_string->add( days => -1 );
Lines 76-85 subtest 'get_expiry_date' => sub { Link Here
76
    is( $category->get_expiry_date, $next_month, 'Without enrolmentperiod and parameter, ->get_expiry_date should return enrolmentperioddate' );
76
    is( $category->get_expiry_date, $next_month, 'Without enrolmentperiod and parameter, ->get_expiry_date should return enrolmentperioddate' );
77
    is( $category->get_expiry_date( $next_year ), $next_month, 'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given' );
77
    is( $category->get_expiry_date( $next_year ), $next_month, 'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given' );
78
78
79
    my $dt = dt_from_string;
80
    my $original_dt = $dt->clone;
81
    $category->get_expiry_date( $dt );
82
    is( t::lib::Dates::compare($dt, $original_dt), 0, 'Without enrolment period, DateTime object passed as a parameter should not be modified when ->get_expiry_date is called');
83
79
    $category->enrolmentperiod( 12 )->store;
84
    $category->enrolmentperiod( 12 )->store;
80
    is( t::lib::Dates::compare($category->get_expiry_date, $next_year), 0, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
85
    is( t::lib::Dates::compare($category->get_expiry_date, $next_year), 0, 'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod' );
81
    is( t::lib::Dates::compare($category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 )), 0, 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
86
    is( t::lib::Dates::compare($category->get_expiry_date( $yesterday ), $next_year->clone->add( days => -1 )), 0, 'With enrolmentperiod defined and a date given in parameter, ->get_expiry_date should take this date + enrolmentperiod' );
82
87
88
    $dt = dt_from_string;
89
    $original_dt = $dt->clone;
90
    $category->get_expiry_date( $dt );
91
    is( t::lib::Dates::compare($dt, $original_dt), 0, 'With enrolment period defined, DateTime object passed as a parameter should not be modified when ->get_expiry_date is called');
92
83
    my $hardcoded_date = '2000-01-31';
93
    my $hardcoded_date = '2000-01-31';
84
    is( t::lib::Dates::compare($category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 )), 0, 'get_expiry_date accepts strings as well'  );
94
    is( t::lib::Dates::compare($category->get_expiry_date( $hardcoded_date ), dt_from_string( $hardcoded_date )->add( months => 12 )), 0, 'get_expiry_date accepts strings as well'  );
85
95
86
- 

Return to bug 34117