Lines 18-24
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use Test::More tests => 74; |
21 |
use Test::More tests => 79; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
Lines 165-171
my $guarantee = {
Link Here
|
165 |
}; |
165 |
}; |
166 |
$guarantee->{'borrowernumber'} = AddMember(%$guarantee); |
166 |
$guarantee->{'borrowernumber'} = AddMember(%$guarantee); |
167 |
|
167 |
|
168 |
my $GUARANTEE_TO_ADDRESS = 'toto@exemple.com'; |
168 |
my $GUARANTEE_TO_ADDRESS = 'guarantor@example.com'; |
169 |
my $guarantee_message = { |
169 |
my $guarantee_message = { |
170 |
borrowernumber => $guarantee->{'borrowernumber'}, |
170 |
borrowernumber => $guarantee->{'borrowernumber'}, |
171 |
message_transport_type => 'email', |
171 |
message_transport_type => 'email', |
Lines 177-183
my $guarantee_message = {
Link Here
|
177 |
sub SendToGuarantor { |
177 |
sub SendToGuarantor { |
178 |
my ($useGuarantor, $message) = @_; |
178 |
my ($useGuarantor, $message) = @_; |
179 |
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' ); |
179 |
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' ); |
180 |
C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', $useGuarantor ); |
180 |
C4::Context->set_preference( 'RedirectGuaranteeEmail', $useGuarantor ); |
181 |
C4::Context->clear_syspref_cache(); |
181 |
C4::Context->clear_syspref_cache(); |
182 |
my $id = C4::Letters::EnqueueLetter($message); |
182 |
my $id = C4::Letters::EnqueueLetter($message); |
183 |
C4::Letters::SendQueuedMessages(); |
183 |
C4::Letters::SendQueuedMessages(); |
Lines 185-206
sub SendToGuarantor {
Link Here
|
185 |
return $result; |
185 |
return $result; |
186 |
} |
186 |
} |
187 |
my $result = SendToGuarantor(0,$guarantee_message); |
187 |
my $result = SendToGuarantor(0,$guarantee_message); |
188 |
is($result->{'status'}, "sent", "With EnableRedirectGuaranteeEmail off, message is sent."); |
188 |
is($result->{'status'}, "sent", "With RedirectGuaranteeEmail off, message is sent."); |
189 |
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With EnableRedirectGuaranteeEmail off, Message is sent to the specified to_address."); |
189 |
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With RedirectGuaranteeEmail off, Message is sent to the specified to_address."); |
190 |
|
190 |
|
191 |
$result = SendToGuarantor(1,$guarantee_message); |
191 |
$result = SendToGuarantor(1,$guarantee_message); |
192 |
is($result->{'status'}, "sent", "With EnableRedirectGuaranteeEmail on, message is sent."); |
192 |
is($result->{'status'}, "sent", "With RedirectGuaranteeEmail on, message is sent."); |
193 |
is($result->{'to_address'}, $GUARANTOR_EMAIL, "With EnableRedirectGuaranteeEmail on, Message is sent to the guarantor's email address."); |
193 |
is($result->{'to_address'}, $GUARANTOR_EMAIL, "With RedirectGuaranteeEmail on, Message is sent to the guarantor's email address."); |
194 |
|
|
|
195 |
$guarantor->{'email'} = undef; |
196 |
ModMember(%$guarantor); |
197 |
$result = SendToGuarantor(1,$guarantee_message); |
198 |
is($result->{'status'}, "failed", "With EnableRedirectGuaranteeEmail on, message fails if guarantor has no address."); |
199 |
|
194 |
|
200 |
$guarantee->{'guarantorid'} = undef; |
195 |
$guarantee->{'guarantorid'} = undef; |
201 |
ModMember(%$guarantee); |
196 |
ModMember(%$guarantee); |
202 |
$result = SendToGuarantor(1,$guarantee_message); |
197 |
$result = SendToGuarantor(1,$guarantee_message); |
203 |
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With EnableRedirectGuaranteeEmail on, Message is sent to specicied to_address if he has no guarantor."); |
198 |
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With RedirectGuaranteeEmail on, Message is sent to specicied to_address if he has no guarantor."); |
204 |
|
199 |
|
205 |
# GetLetters |
200 |
# GetLetters |
206 |
my $letters = C4::Letters::GetLetters(); |
201 |
my $letters = C4::Letters::GetLetters(); |