Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 57; |
20 |
use Test::More tests => 50; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Exception; |
22 |
use Test::Exception; |
23 |
|
23 |
|
Lines 101-155
ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME &&
Link Here
|
101 |
, "Member Changed") |
101 |
, "Member Changed") |
102 |
or diag("Mismatching member details: ".Dumper($member, $changedmember)); |
102 |
or diag("Mismatching member details: ".Dumper($member, $changedmember)); |
103 |
|
103 |
|
104 |
# Test notice_email_address |
104 |
# Add a new borrower |
105 |
# Add Guarantor for testing |
|
|
106 |
my $GUARANTOR_EMAIL = "Robert\@email.com"; |
107 |
%data = ( |
105 |
%data = ( |
108 |
cardnumber => "2997924548", |
106 |
cardnumber => "123456789", |
109 |
firstname => "Robert", |
107 |
firstname => "Tomasito", |
110 |
surname => "Tables", |
108 |
surname => "None", |
111 |
categorycode => $patron_category->{categorycode}, |
109 |
categorycode => $patron_category->{categorycode}, |
112 |
branchcode => $BRANCHCODE, |
110 |
branchcode => $library2->{branchcode}, |
113 |
dateofbirth => '', |
111 |
dateofbirth => '', |
114 |
dateexpiry => '9999-12-31', |
112 |
debarred => '', |
115 |
userid => 'bobbytables', |
113 |
dateexpiry => '', |
116 |
email => $GUARANTOR_EMAIL |
114 |
dateenrolled => '', |
117 |
); |
|
|
118 |
|
119 |
$addmem=Koha::Patron->new(\%data)->store->borrowernumber; |
120 |
ok($addmem, "Koha::Patron->store()"); |
121 |
|
122 |
my $patron_guarantor = Koha::Patrons->find( { cardnumber => (\%data)->{'cardnumber'} } ) |
123 |
or BAIL_OUT("Cannot read member with card (\%data)->{'cardnumber'}"); |
124 |
my $member_guarantor = $patron_guarantor->unblessed; |
125 |
|
126 |
my %data2 = ( |
127 |
guarantor_id => $member_guarantor->{borrowernumber}, |
128 |
guarantee_id => $member->{borrowernumber}, |
129 |
relationship => "father" |
130 |
); |
115 |
); |
131 |
Koha::Patron::Relationship->new(\%data2)->store; |
116 |
my $borrowernumber = Koha::Patron->new( \%data )->store->borrowernumber; |
132 |
|
117 |
$patron = Koha::Patrons->find( $borrowernumber ); |
133 |
$member = Koha::Patrons->find( { cardnumber => $CARDNUMBER } ); |
118 |
my $borrower = $patron->unblessed; |
134 |
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); |
|
|
135 |
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); |
136 |
C4::Context->clear_syspref_cache(); |
137 |
|
138 |
my $notice_email = $member->notice_email_address; |
139 |
is ($notice_email, $EMAIL, "notice_email_address returns correct value when EmailFieldPrimary is off"); |
140 |
|
141 |
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' ); |
142 |
C4::Context->clear_syspref_cache(); |
143 |
|
144 |
$notice_email = $member->notice_email_address; |
145 |
is ($notice_email, $EMAILPRO, "notice_email_address returns correct value when EmailFieldPrimary is emailpro"); |
146 |
|
147 |
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); |
148 |
t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' ); |
149 |
C4::Context->clear_syspref_cache(); |
150 |
$notice_email = $member->notice_email_address; |
151 |
is ($notice_email, $EMAIL . ", " . $GUARANTOR_EMAIL, "notice_email_address returns correct value when RedirectGuaranteeEmail is enabled"); |
152 |
|
153 |
is( $borrower->{dateofbirth}, undef, 'Koha::Patron->store should undef dateofbirth if empty string is given'); |
119 |
is( $borrower->{dateofbirth}, undef, 'Koha::Patron->store should undef dateofbirth if empty string is given'); |
154 |
is( $borrower->{debarred}, undef, 'Koha::Patron->store should undef debarred if empty string is given'); |
120 |
is( $borrower->{debarred}, undef, 'Koha::Patron->store should undef debarred if empty string is given'); |
155 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'Koha::Patron->store should not set dateexpiry to 0000-00-00 if empty string is given'); |
121 |
isnt( $borrower->{dateexpiry}, '0000-00-00', 'Koha::Patron->store should not set dateexpiry to 0000-00-00 if empty string is given'); |
156 |
- |
|
|