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

(-)a/t/db_dependent/Letters.t (-13 / +8 lines)
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();
(-)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 => 84;
20
use Test::More tests => 85;
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 153-159 is ($checkcardnum, "2", "Card number is too long"); Link Here
153
153
154
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
154
t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'OFF' );
155
155
156
C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', 0 );
156
C4::Context->set_preference( 'RedirectGuaranteeEmail', 0 );
157
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
157
C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'OFF' );
158
C4::Context->clear_syspref_cache();
158
C4::Context->clear_syspref_cache();
159
159
Lines 178-190 my $guarantee = { Link Here
178
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
178
$guarantee->{'borrowernumber'} = AddMember(%$guarantee);
179
179
180
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
180
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
181
is ($notice_email, $GUARANTEE_EMAIL, "GetNoticeEmailAddress returns correct value when EnableRedirectGuaranteeEmail is disabled");
181
is ($notice_email, $GUARANTEE_EMAIL, "GetNoticeEmailAddress returns correct value when RedirectGuaranteeEmail is disabled");
182
182
183
C4::Context->set_preference( 'EnableRedirectGuaranteeEmail', 1 );
183
C4::Context->set_preference( 'RedirectGuaranteeEmail', 1 );
184
C4::Context->clear_syspref_cache();
184
C4::Context->clear_syspref_cache();
185
185
186
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
186
$notice_email = GetNoticeEmailAddress($guarantee->{'borrowernumber'});
187
is ($notice_email, $EMAILPRO, "GetNoticeEmailAddress returns correct value when EnableRedirectGuaranteeEmail is activated");
187
is ($notice_email, "$GUARANTEE_EMAIL,$EMAILPRO", "GetNoticeEmailAddress returns correct value when RedirectGuaranteeEmail is activated");
188
188
189
189
190
ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired");
190
ok(!$member->{is_expired}, "GetMemberDetails() indicates that patron is not expired");
Lines 328-334 my $borrower2 = $builder->build({ Link Here
328
        },
328
        },
329
});
329
});
330
330
331
my $guarantee = $builder->build({
331
$guarantee = $builder->build({
332
        source => 'Borrower',
332
        source => 'Borrower',
333
        value  => {
333
        value  => {
334
            categorycode=>'KIDclamp',
334
            categorycode=>'KIDclamp',
335
- 

Return to bug 12532