View | Details | Raw Unified | Return to bug 12532
Collapse All | Expand All

(-)a/t/db_dependent/Letters.t (-20 / +14 lines)
Lines 149-172 $resent = C4::Letters::ResendMessage(); Link Here
149
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
149
is( $resent, undef, 'ResendMessage should return undef if not message_id given' );
150
150
151
#Test guarantee-guarantor email redirection
151
#Test guarantee-guarantor email redirection
152
$library = $builder->build({
153
     source => 'Branch',
154
 });
152
my ($GUARANTEE_EMAIL, $GUARANTOR_EMAIL) = qw| guarantee@example.com guarantor@example.com |;
155
my ($GUARANTEE_EMAIL, $GUARANTOR_EMAIL) = qw| guarantee@example.com guarantor@example.com |;
156
my $guarantor_category = $builder->build({ source => 'Category' });
153
my $guarantor = {
157
my $guarantor = {
154
    email        => $GUARANTOR_EMAIL,
158
    email        => $GUARANTOR_EMAIL,
155
    categorycode => 'PT',
159
    categorycode => $guarantor_category,
156
    branchcode   => 'CPL',
160
    branchcode   => $library->{branchcode},
157
    surname      => "Guarantor"
161
    surname      => "Guarantor"
158
};
162
};
159
$guarantor->{'borrowernumber'} = AddMember(%$guarantor);
163
$guarantor->{'borrowernumber'} = AddMember(%$guarantor);
160
my $guarantee = {
164
my $guarantee = {
161
    guarantorid  => $guarantor->{'borrowernumber'},
165
    guarantorid  => $guarantor->{'borrowernumber'},
162
    email        => $GUARANTEE_EMAIL,
166
    email        => $GUARANTEE_EMAIL,
163
    categorycode => 'PT',
167
    categorycode => $guarantor_category,
164
    branchcode   => 'CPL',
168
    branchcode   => $library->{branchcode},
165
    surname      => "Guarantee"
169
    surname      => "Guarantee"
166
};
170
};
167
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
171
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
168
172
169
my $GUARANTEE_TO_ADDRESS = 'toto@exemple.com';
173
my $GUARANTEE_TO_ADDRESS = 'guarantor@example.com';
170
my $guarantee_message = {
174
my $guarantee_message = {
171
    borrowernumber         => $guarantee->{'borrowernumber'},
175
    borrowernumber         => $guarantee->{'borrowernumber'},
172
    message_transport_type => 'email',
176
    message_transport_type => 'email',
Lines 178-184 my $guarantee_message = { Link Here
178
sub SendToGuarantor {
182
sub SendToGuarantor {
179
    my ($useGuarantor, $message) = @_;
183
    my ($useGuarantor, $message) = @_;
180
    C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
184
    C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
181
    C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', $useGuarantor );
185
    C4::Context->set_preference( 'RedirectGuaranteeEmail', $useGuarantor );
182
    C4::Context->clear_syspref_cache();
186
    C4::Context->clear_syspref_cache();
183
    my $id = C4::Letters::EnqueueLetter($message);
187
    my $id = C4::Letters::EnqueueLetter($message);
184
    C4::Letters::SendQueuedMessages();
188
    C4::Letters::SendQueuedMessages();
Lines 186-207 sub SendToGuarantor { Link Here
186
    return $result;
190
    return $result;
187
}
191
}
188
my $result = SendToGuarantor(0,$guarantee_message);
192
my $result = SendToGuarantor(0,$guarantee_message);
189
is($result->{'status'}, "sent", "With EnableRedirectGuaranteeEmail off, message is sent.");
193
is($result->{'status'}, "sent", "With RedirectGuaranteeEmail off, message is sent.");
190
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With EnableRedirectGuaranteeEmail off, Message is sent to the specified to_address.");
194
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With RedirectGuaranteeEmail off, Message is sent to the specified to_address.");
191
192
$result = SendToGuarantor(1,$guarantee_message);
193
is($result->{'status'}, "sent", "With EnableRedirectGuaranteeEmail on, message is sent.");
194
is($result->{'to_address'}, $GUARANTOR_EMAIL, "With EnableRedirectGuaranteeEmail on, Message is sent to the guarantor's email address.");
195
196
$guarantor->{'email'} = undef;
197
ModMember(%$guarantor);
198
$result = SendToGuarantor(1,$guarantee_message);
199
is($result->{'status'}, "failed", "With EnableRedirectGuaranteeEmail on, message fails if guarantor has no address.");
200
195
201
$guarantee->{'guarantorid'} = undef;
202
ModMember(%$guarantee);
203
$result = SendToGuarantor(1,$guarantee_message);
196
$result = SendToGuarantor(1,$guarantee_message);
204
is($result->{'to_address'}, $GUARANTEE_TO_ADDRESS, "With EnableRedirectGuaranteeEmail on, Message is sent to specicied to_address if he has no guarantor.");
197
is($result->{'status'}, "sent", "With RedirectGuaranteeEmail on, message is sent.");
198
is($result->{'to_address'}, $GUARANTOR_EMAIL, "With RedirectGuaranteeEmail on, Message is sent to the guarantor's email address.");
205
199
206
# GetLetters
200
# GetLetters
207
my $letters = C4::Letters::GetLetters();
201
my $letters = C4::Letters::GetLetters();
(-)a/t/db_dependent/Members.t (-7 / +6 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 64;
20
use Test::More tests => 87;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Data::Dumper;
22
use Data::Dumper;
23
use C4::Context;
23
use C4::Context;
Lines 140-146 is ($checkcardnum, "2", "Card number is too long"); Link Here
140
140
141
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
141
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
142
142
143
C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', 0 );
143
C4::Context->set_preference( 'RedirectGuaranteeEmail', 0 );
144
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
144
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
145
C4::Context->clear_syspref_cache();
145
C4::Context->clear_syspref_cache();
146
146
Lines 165-177 my $guarantee = { Link Here
165
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
165
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
166
166
167
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
167
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
168
is ($notice_email, $GUARANTEE_EMAIL, "GetNoticeEmailAddress returns correct value when EnableRedirectGuaranteeEmail is disabled");
168
is ($notice_email, $GUARANTEE_EMAIL, "GetNoticeEmailAddress returns correct value when RedirectGuaranteeEmail is disabled");
169
169
170
C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', 1 );
170
C4::Context->set_preference( 'RedirectGuaranteeEmail', 1 );
171
C4::Context->clear_syspref_cache();
171
C4::Context->clear_syspref_cache();
172
172
173
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
173
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
174
is ($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when EnableRedirectGuaranteeEmail is activated");
174
is ($notice_email, "$GUARANTEE_EMAIL,$EMAILPRO", "GetNoticeEmailAddress returns correct value when RedirectGuaranteeEmail is activated");
175
175
176
176
177
ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired");
177
ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired");
Lines 317-323 my $borrower2 = $builder->build({ Link Here
317
        },
317
        },
318
});
318
});
319
319
320
my $guarantee = $builder->build({
320
$guarantee = $builder->build({
321
        source => 'Borrower',
321
        source => 'Borrower',
322
        value  => {
322
        value  => {
323
            categorycode=>'KIDclamp',
323
            categorycode=>'KIDclamp',
324
- 

Return to bug 12532