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( |
83 |
t::lib::Dates::compare( $dt, $original_dt ), 0, |
84 |
'Without enrolment period, DateTime object passed as a parameter should not be modified when ->get_expiry_date is called' |
85 |
); |
86 |
|
79 |
$category->enrolmentperiod( 12 )->store; |
87 |
$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' ); |
88 |
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' ); |
89 |
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 |
|
90 |
|
|
|
91 |
$dt = dt_from_string; |
92 |
$original_dt = $dt->clone; |
93 |
$category->get_expiry_date($dt); |
94 |
is( |
95 |
t::lib::Dates::compare( $dt, $original_dt ), 0, |
96 |
'With enrolment period defined, DateTime object passed as a parameter should not be modified when ->get_expiry_date is called' |
97 |
); |
98 |
|
83 |
my $hardcoded_date = '2000-01-31'; |
99 |
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' ); |
100 |
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 |
|
101 |
|
86 |
- |
|
|