Bug 16911: Koha::Patron::Categories - Add tests for ->get_expiry_date
Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
is(scalar(grep{$_eq$new_category_1->categorycode}@limited_category_codes),0,'The first category is limited to another branch');
is(scalar(grep{$_eq$new_category_2->categorycode}@limited_category_codes),1,'The second category is not limited');
is(scalar(grep{$_eq$new_category_3->categorycode}@limited_category_codes),1,'The third category is limited to my branch ');
description=>'mycatdesc',
enrolmentperiod=>undef,
enrolmentperioddate=>$next_month,
})->store;
is($category->get_expiry_date,$next_month,'Without enrolmentperiod and parameter, ->get_expiry_date should return enrolmentperioddate');
is($category->get_expiry_date($next_year),$next_month,'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given');
is(scalar(grep{$_eq$new_category_2->categorycode}@limited_category_codes_for_A),0,'The second category is not limited but has a category_type S');
is(scalar(grep{$_eq$new_category_3->categorycode}@limited_category_codes_for_A),1,'The third category is limited to my branch and has a category_type A');
$category->enrolmentperiod(12)->store;
is($category->get_expiry_date,$next_year,'With enrolmentperiod defined and no parameter, ->get_expiry_date should return today + enrolmentperiod');
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');
$category->delete;
};
$retrieved_category_1->delete;
is(Koha::Patron::Categories->search->count,$nb_of_categories+2,'Delete should have deleted the patron category');