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>.
22 use Test
::More tests
=> 5;
24 use t
::lib
::TestBuilder
;
25 use t
::lib
::Mocks
qw( mock_preference );
31 use_ok
('C4::Members');
34 my $schema = Koha
::Database
->new->schema;
35 $schema->storage->txn_begin;
37 my $date_time = new Test
::MockModule
('DateTime');
48 t
::lib
::Mocks
::mock_preference
('MembershipExpiryDaysNotice', 15);
50 my $builder = t
::lib
::TestBuilder
->new();
55 description
=> 'Adult',
56 enrolmentperiod
=> 18,
66 branchname
=> 'My branch',
73 firstname
=> 'Vincent',
75 cardnumber
=> '80808081',
78 dateexpiry
=> '2015-06-30'
85 firstname
=> 'Claude',
87 cardnumber
=> '80808082',
90 dateexpiry
=> '2015-06-29'
97 firstname
=> 'Gilles',
99 cardnumber
=> '80808083',
100 categorycode
=> 'AD',
102 dateexpiry
=> '2015-07-02'
106 my $upcoming_mem_expires = C4
::Members
::GetUpcomingMembershipExpires
();
107 is
(scalar(@
$upcoming_mem_expires), 1, 'Get upcoming membership expires should return 1 borrower.');
109 is
($upcoming_mem_expires->[0]{surname
}, 'Martin', 'Get upcoming membership expires should return borrower "Martin".');
111 # Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == 0
112 t
::lib
::Mocks
::mock_preference
('MembershipExpiryDaysNotice', 0);
114 $upcoming_mem_expires = C4
::Members
::GetUpcomingMembershipExpires
();
115 is
(scalar(@
$upcoming_mem_expires), 0, 'Get upcoming membership expires with 0 MembershipExpiryDaysNotice should return 0.');
117 # Test GetUpcomingMembershipExpires() with MembershipExpiryDaysNotice == undef
118 t
::lib
::Mocks
::mock_preference
('MembershipExpiryDaysNotice', undef);
120 $upcoming_mem_expires = C4
::Members
::GetUpcomingMembershipExpires
();
121 is
(scalar(@
$upcoming_mem_expires), 0, 'Get upcoming membership expires without MembershipExpiryDaysNotice should return 0.');
123 $schema->storage->txn_rollback;