Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
|
|
21 |
|
22 |
use Test::MockModule; |
21 |
use Test::Exception; |
23 |
use Test::Exception; |
22 |
|
24 |
|
23 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
Lines 175-177
subtest 'create() tests' => sub {
Link Here
|
175 |
is( "$@", q{Invalid 'bcc' parameter: not_an_email}, 'Exception message correct' ); |
177 |
is( "$@", q{Invalid 'bcc' parameter: not_an_email}, 'Exception message correct' ); |
176 |
}; |
178 |
}; |
177 |
}; |
179 |
}; |
178 |
- |
180 |
|
|
|
181 |
subtest 'send_or_die() tests' => sub { |
182 |
|
183 |
plan tests => 4; |
184 |
|
185 |
my $email; |
186 |
my $args; |
187 |
|
188 |
my $transport = "Hi there!"; |
189 |
|
190 |
my $mocked_email_simple = Test::MockModule->new('Email::Sender::Simple'); |
191 |
$mocked_email_simple->mock( |
192 |
'send', |
193 |
sub { |
194 |
my @params = @_; |
195 |
$email = $params[1]; |
196 |
$args = $params[2]; |
197 |
return; |
198 |
} |
199 |
); |
200 |
|
201 |
my $html_body = '<h1>Title</h1><p>Message</p>'; |
202 |
my $THE_email = Koha::Email->create( |
203 |
{ |
204 |
from => 'from@example.com', |
205 |
to => 'to@example.com', |
206 |
cc => 'cc@example.com', |
207 |
reply_to => 'reply_to@example.com', |
208 |
sender => 'sender@example.com', |
209 |
html_body => $html_body |
210 |
} |
211 |
); |
212 |
|
213 |
my @bcc = ( 'bcc_1@example.com', 'bcc_2@example.com' ); |
214 |
|
215 |
$THE_email->bcc(@bcc); |
216 |
|
217 |
is( |
218 |
$THE_email->email->header_str('Bcc'), |
219 |
join( ', ', @bcc ), |
220 |
'Bcc header set correctly' |
221 |
); |
222 |
|
223 |
$THE_email->send_or_die( |
224 |
{ transport => $transport, to => ['tomasito@mail.com'] } ); |
225 |
is_deeply( $args->{to}, ['tomasito@mail.com'], |
226 |
'If explicitly passed, "to" is preserved' ); |
227 |
|
228 |
$THE_email->send_or_die( { transport => $transport } ); |
229 |
is_deeply( |
230 |
$args->{to}, |
231 |
[ |
232 |
'to@example.com', 'cc@example.com', |
233 |
'bcc_1@example.com', 'bcc_2@example.com' |
234 |
], |
235 |
'If explicitly passed, "to" is preserved' |
236 |
); |
237 |
is( $email->header_str('Bcc'), undef, 'The Bcc header is unset' ); |
238 |
}; |