3 # This file is part of Koha.
5 # Copyright 2015 Biblibre
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use t::lib::TestBuilder;
24 use t::lib::Mocks qw( mock_preference );
26 use Test::More tests => 5;
30 use_ok('C4::Members');
33 my $date_time = new Test::MockModule('DateTime');
44 t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 15);
46 my $builder = t::lib::TestBuilder->new();
51 description => 'Adult',
52 enrolmentperiod => 18,
62 branchname => 'My branch',
69 firstname => 'Vincent',
71 cardnumber => '80808081',
74 dateexpiry => '2015-06-30'
81 firstname => 'Claude',
83 cardnumber => '80808082',
86 dateexpiry => '2015-06-29'
93 firstname => 'Gilles',
95 cardnumber => '80808083',
98 dateexpiry => '2015-07-02'
102 my $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
103 is(scalar(@$upcoming_mem_expires), 1, 'Get upcoming membership expires should return 1 borrower.');
105 is($upcoming_mem_expires->[0]{surname}, 'Martin', 'Get upcoming membership expires should return borrower "Martin".');
107 # Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == 0
108 t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', 0);
110 $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
111 is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires with 0 MembershipExpiryDaysNotice should return 0.');
113 # Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == undef
114 t::lib::Mocks::mock_preference('MembershipExpiryDaysNotice', undef);
116 $upcoming_mem_expires = C4::Members::GetUpcomingMembershipExpires();
117 is(scalar(@$upcoming_mem_expires), 0, 'Get upcoming membership expires without MembershipExpiryDaysNotice should return 0.');