|
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 => 15; |
21 |
use Test::More tests => 16; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
| 24 |
use MARC::Record; |
24 |
use MARC::Record; |
|
Lines 39-44
use Koha::Serial;
Link Here
|
| 39 |
use Koha::Subscription; |
39 |
use Koha::Subscription; |
| 40 |
use Koha::Suggestion; |
40 |
use Koha::Suggestion; |
| 41 |
use Koha::Checkout; |
41 |
use Koha::Checkout; |
|
|
42 |
use Koha::Notice::Templates; |
| 42 |
use Koha::Patron::Modification; |
43 |
use Koha::Patron::Modification; |
| 43 |
|
44 |
|
| 44 |
my $schema = Koha::Database->schema; |
45 |
my $schema = Koha::Database->schema; |
|
Lines 279-281
$prepared_letter = GetPreparedLetter(
Link Here
|
| 279 |
) |
280 |
) |
| 280 |
); |
281 |
); |
| 281 |
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); |
282 |
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); |
| 282 |
- |
283 |
|
|
|
284 |
subtest 'regression tests' => sub { |
| 285 |
plan tests => 1; |
| 286 |
|
| 287 |
my $library = $builder->build( { source => 'Branch' } ); |
| 288 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 289 |
my $biblio = Koha::Biblio->new({title => 'Test Biblio'})->store->unblessed; |
| 290 |
my $biblioitem = Koha::Biblioitem->new({biblionumber => $biblio->{biblionumber}})->store()->unblessed; |
| 291 |
my $item1 = Koha::Item->new( |
| 292 |
{ |
| 293 |
biblionumber => $biblio->{biblionumber}, |
| 294 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
| 295 |
} |
| 296 |
)->store->unblessed; |
| 297 |
my $item2 = Koha::Item->new( |
| 298 |
{ |
| 299 |
biblionumber => $biblio->{biblionumber}, |
| 300 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
| 301 |
} |
| 302 |
)->store->unblessed; |
| 303 |
|
| 304 |
subtest 'ACQ_NOTIF_ON_RECEIV ' => sub { |
| 305 |
plan tests => 1; |
| 306 |
my $code = 'ACQ_NOTIF_ON_RECEIV'; |
| 307 |
my $branchcode = $library->{branchcode}; |
| 308 |
my $order = $builder->build({ source => 'Aqorder' }); |
| 309 |
|
| 310 |
my $template = q| |
| 311 |
Dear <<borrowers.firstname>> <<borrowers.surname>>, |
| 312 |
The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received. |
| 313 |
Your library. |
| 314 |
|; |
| 315 |
my $params = { code => $code, branchcode => $branchcode, tables => { branches => $library, borrowers => $patron, biblio => $biblio, aqorders => $order } }; |
| 316 |
my $letter = process_letter( { template => $template, %$params }); |
| 317 |
my $tt_template = q| |
| 318 |
Dear [% borrower.firstname %] [% borrower.surname %], |
| 319 |
The order [% order.ordernumber %] ([% biblio.title %]) has been received. |
| 320 |
Your library. |
| 321 |
|; |
| 322 |
my $tt_letter = process_letter( { template => $tt_template, %$params }); |
| 323 |
|
| 324 |
is( $tt_letter->{content}, $letter->{content}, ); |
| 325 |
}; |
| 326 |
}; |
| 327 |
|
| 328 |
sub reset_template { |
| 329 |
my ( $params ) = @_; |
| 330 |
my $template = $params->{template}; |
| 331 |
my $code = $params->{code}; |
| 332 |
my $module = $params->{module} || 'test_module'; |
| 333 |
|
| 334 |
Koha::Notice::Templates->search( { code => $code } )->delete; |
| 335 |
Koha::Notice::Template->new( |
| 336 |
{ |
| 337 |
module => $module, |
| 338 |
code => $code, |
| 339 |
branchcode => '', |
| 340 |
name => $code, |
| 341 |
title => $code, |
| 342 |
message_transport_type => 'email', |
| 343 |
content => $template |
| 344 |
} |
| 345 |
)->store; |
| 346 |
} |
| 347 |
|
| 348 |
sub process_letter { |
| 349 |
my ($params) = @_; |
| 350 |
my $template = $params->{template}; |
| 351 |
my $tables = $params->{tables}; |
| 352 |
my $substitute = $params->{substitute}; |
| 353 |
my $code = $params->{code}; |
| 354 |
my $module = $params->{module} || 'test_module'; |
| 355 |
my $branchcode = $params->{branchcode}; |
| 356 |
|
| 357 |
reset_template( $params ); |
| 358 |
|
| 359 |
my $letter = C4::Letters::GetPreparedLetter( |
| 360 |
module => $module, |
| 361 |
letter_code => $code, |
| 362 |
branchcode => '', |
| 363 |
tables => $tables, |
| 364 |
substitute => $substitute, |
| 365 |
); |
| 366 |
return $letter; |
| 367 |
} |