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 => 5;
22
use Test::More tests => 6;
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 49-54 is( $retrieved_category_1->categorycode, $new_category_1->categorycode, 'Find a Link Here
49
is_deeply( $retrieved_category_1->branch_limitations, [ $branch->{branchcode} ], 'The branch limitation should have been stored and retrieved' );
50
is_deeply( $retrieved_category_1->branch_limitations, [ $branch->{branchcode} ], 'The branch limitation should have been stored and retrieved' );
50
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' );
51
52
53
subtest 'get_expiry_date' => sub {
54
    plan tests => 4;
55
    my $next_month = dt_from_string->add( months => 1 );
56
    my $next_year = dt_from_string->add( months => 12 );
57
    my $yesterday = dt_from_string->add( days => -1 );
58
    my $category = Koha::Patron::Category->new({
59
        categorycode => 'mycat',
60
        category_type => 'A',
61
        description  => 'mycatdesc',
62
        enrolmentperiod => undef,
63
        enrolmentperioddate => $next_month,
64
    })->store;
65
    is( $category->get_expiry_date, $next_month, 'Without enrolmentperiod and parameter, ->get_expiry_date should return enrolmentperioddate' );
66
    is( $category->get_expiry_date( $next_year ), $next_month, 'Without enrolmentperiod, ->get_expiry_date should return enrolmentperiodadate even if a parameter is given' );
67
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' );
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
    $category->delete;
72
};
73
52
$retrieved_category_1->delete;
74
$retrieved_category_1->delete;
53
is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' );
75
is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' );
54
76
55
- 

Return to bug 16911