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

(-)a/t/db_dependent/Koha/Patron/Categories.t (-2 / +23 lines)
Lines 19-27 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 7;
22
use Test::More tests => 8;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::DateUtils;
25
use Koha::Patron::Category;
26
use Koha::Patron::Category;
26
use Koha::Patron::Categories;
27
use Koha::Patron::Categories;
27
use t::lib::TestBuilder;
28
use t::lib::TestBuilder;
Lines 54-59 my $retrieved_category_2 = Koha::Patron::Categories->find( $new_category_2->cate Link Here
54
is( $retrieved_category_1->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
55
is( $retrieved_category_1->checkprevcheckout, 'inherit', 'Koha::Patron::Category->store should default checkprevcheckout to inherit' );
55
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' );
56
57
58
subtest 'get_expiry_date' => sub {
59
    plan tests => 4;
60
    my $next_month = dt_from_string->add( months => 1 );
61
    my $next_year = dt_from_string->add( months => 12 );
62
    my $yesterday = dt_from_string->add( days => -1 );
63
    my $category = Koha::Patron::Category->new({
64
        categorycode => 'mycat',
65
        category_type => 'A',
66
        description  => 'mycatdesc',
67
        enrolmentperiod => undef,
68
        enrolmentperioddate => $next_month,
69
    })->store;
70
    is( $category->get_expiry_date, $next_month, 'Without enrolmentperiod and parameter, ->get_expiry_date should return enrolmentperioddate' );
71
    is( $category->get_expiry_date( $next_year ), $next_month, 'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given' );
72
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' );
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
    $category->delete;
77
};
78
57
$retrieved_category_1->delete;
79
$retrieved_category_1->delete;
58
is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' );
80
is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' );
59
81
60
- 

Return to bug 16911