Lines 26-31
use MARC::Record;
Link Here
|
26 |
|
26 |
|
27 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
28 |
|
28 |
|
|
|
29 |
use C4::Circulation; |
29 |
use C4::Letters; |
30 |
use C4::Letters; |
30 |
use C4::Members; |
31 |
use C4::Members; |
31 |
use C4::Biblio; |
32 |
use C4::Biblio; |
Lines 285-309
$prepared_letter = GetPreparedLetter(
Link Here
|
285 |
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); |
286 |
is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); |
286 |
|
287 |
|
287 |
subtest 'regression tests' => sub { |
288 |
subtest 'regression tests' => sub { |
288 |
plan tests => 2; |
289 |
plan tests => 3; |
289 |
|
290 |
|
290 |
my $library = $builder->build( { source => 'Branch' } ); |
291 |
my $library = $builder->build( { source => 'Branch' } ); |
291 |
my $patron = $builder->build( { source => 'Borrower' } ); |
292 |
my $patron = $builder->build( { source => 'Borrower' } ); |
292 |
my $biblio = Koha::Biblio->new({title => 'Test Biblio'})->store->unblessed; |
293 |
my $biblio1 = Koha::Biblio->new({title => 'Test Biblio 1'})->store->unblessed; |
293 |
my $biblioitem = Koha::Biblioitem->new({biblionumber => $biblio->{biblionumber}})->store()->unblessed; |
294 |
my $biblioitem1 = Koha::Biblioitem->new({biblionumber => $biblio1->{biblionumber}})->store()->unblessed; |
294 |
my $item1 = Koha::Item->new( |
295 |
my $item1 = Koha::Item->new( |
295 |
{ |
296 |
{ |
296 |
biblionumber => $biblio->{biblionumber}, |
297 |
biblionumber => $biblio1->{biblionumber}, |
297 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
298 |
biblioitemnumber => $biblioitem1->{biblioitemnumber}, |
|
|
299 |
barcode => 'a_t_barcode', |
300 |
homebranch => $library->{branchcode}, |
301 |
holdingbranch => $library->{branchcode}, |
302 |
itype => 'BK', |
298 |
} |
303 |
} |
299 |
)->store->unblessed; |
304 |
)->store->unblessed; |
|
|
305 |
my $biblio2 = Koha::Biblio->new({title => 'Test Biblio 2'})->store->unblessed; |
306 |
my $biblioitem2 = Koha::Biblioitem->new({biblionumber => $biblio2->{biblionumber}})->store()->unblessed; |
300 |
my $item2 = Koha::Item->new( |
307 |
my $item2 = Koha::Item->new( |
301 |
{ |
308 |
{ |
302 |
biblionumber => $biblio->{biblionumber}, |
309 |
biblionumber => $biblio2->{biblionumber}, |
303 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
310 |
biblioitemnumber => $biblioitem2->{biblioitemnumber}, |
|
|
311 |
barcode => 'another_t_barcode', |
312 |
homebranch => $library->{branchcode}, |
313 |
holdingbranch => $library->{branchcode}, |
314 |
itype => 'BK', |
304 |
} |
315 |
} |
305 |
)->store->unblessed; |
316 |
)->store->unblessed; |
306 |
|
317 |
|
|
|
318 |
C4::Context->_new_userenv('xxx'); |
319 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', ''); |
320 |
|
307 |
subtest 'ACQ_NOTIF_ON_RECEIV ' => sub { |
321 |
subtest 'ACQ_NOTIF_ON_RECEIV ' => sub { |
308 |
plan tests => 1; |
322 |
plan tests => 1; |
309 |
my $code = 'ACQ_NOTIF_ON_RECEIV'; |
323 |
my $code = 'ACQ_NOTIF_ON_RECEIV'; |
Lines 311-326
subtest 'regression tests' => sub {
Link Here
|
311 |
my $order = $builder->build({ source => 'Aqorder' }); |
325 |
my $order = $builder->build({ source => 'Aqorder' }); |
312 |
|
326 |
|
313 |
my $template = q| |
327 |
my $template = q| |
314 |
Dear <<borrowers.firstname>> <<borrowers.surname>>, |
328 |
Dear <<borrowers.firstname>> <<borrowers.surname>>, |
315 |
The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received. |
329 |
The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received. |
316 |
Your library. |
330 |
Your library. |
317 |
|; |
331 |
|; |
318 |
my $params = { code => $code, branchcode => $branchcode, tables => { branches => $library, borrowers => $patron, biblio => $biblio, aqorders => $order } }; |
332 |
my $params = { code => $code, branchcode => $branchcode, tables => { branches => $library, borrowers => $patron, biblio => $biblio1, aqorders => $order } }; |
319 |
my $letter = process_letter( { template => $template, %$params }); |
333 |
my $letter = process_letter( { template => $template, %$params }); |
320 |
my $tt_template = q| |
334 |
my $tt_template = q| |
321 |
Dear [% borrower.firstname %] [% borrower.surname %], |
335 |
Dear [% borrower.firstname %] [% borrower.surname %], |
322 |
The order [% order.ordernumber %] ([% biblio.title %]) has been received. |
336 |
The order [% order.ordernumber %] ([% biblio.title %]) has been received. |
323 |
Your library. |
337 |
Your library. |
324 |
|; |
338 |
|; |
325 |
my $tt_letter = process_letter( { template => $tt_template, %$params }); |
339 |
my $tt_letter = process_letter( { template => $tt_template, %$params }); |
326 |
|
340 |
|
Lines 333-353
subtest 'regression tests' => sub {
Link Here
|
333 |
my $branchcode = $library->{branchcode}; |
347 |
my $branchcode = $library->{branchcode}; |
334 |
|
348 |
|
335 |
my $template = q| |
349 |
my $template = q| |
336 |
<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>) |
350 |
<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>) |
337 |
|
351 |
|
338 |
Your request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason: |
352 |
Your request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason: |
339 |
|
353 |
|
340 |
<<article_requests.notes>> |
354 |
<<article_requests.notes>> |
341 |
|
355 |
|
342 |
Article requested: |
356 |
Article requested: |
343 |
Title: <<article_requests.title>> |
357 |
Title: <<article_requests.title>> |
344 |
Author: <<article_requests.author>> |
358 |
Author: <<article_requests.author>> |
345 |
Volume: <<article_requests.volume>> |
359 |
Volume: <<article_requests.volume>> |
346 |
Issue: <<article_requests.issue>> |
360 |
Issue: <<article_requests.issue>> |
347 |
Date: <<article_requests.date>> |
361 |
Date: <<article_requests.date>> |
348 |
Pages: <<article_requests.pages>> |
362 |
Pages: <<article_requests.pages>> |
349 |
Chapters: <<article_requests.chapters>> |
363 |
Chapters: <<article_requests.chapters>> |
350 |
Notes: <<article_requests.patron_notes>> |
364 |
Notes: <<article_requests.patron_notes>> |
351 |
|; |
365 |
|; |
352 |
reset_template( { template => $template, code => $code, module => 'circulation' } ); |
366 |
reset_template( { template => $template, code => $code, module => 'circulation' } ); |
353 |
my $article_request = $builder->build({ source => 'ArticleRequest' }); |
367 |
my $article_request = $builder->build({ source => 'ArticleRequest' }); |
Lines 355-375
subtest 'regression tests' => sub {
Link Here
|
355 |
my $letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
369 |
my $letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
356 |
|
370 |
|
357 |
my $tt_template = q| |
371 |
my $tt_template = q| |
358 |
[% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %]) |
372 |
[% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %]) |
359 |
|
373 |
|
360 |
Your request for an article from [% biblio.title %] ([% item.barcode %]) has been canceled for the following reason: |
374 |
Your request for an article from [% biblio.title %] ([% item.barcode %]) has been canceled for the following reason: |
361 |
|
375 |
|
362 |
[% article_request.notes %] |
376 |
[% article_request.notes %] |
363 |
|
377 |
|
364 |
Article requested: |
378 |
Article requested: |
365 |
Title: [% article_request.title %] |
379 |
Title: [% article_request.title %] |
366 |
Author: [% article_request.author %] |
380 |
Author: [% article_request.author %] |
367 |
Volume: [% article_request.volume %] |
381 |
Volume: [% article_request.volume %] |
368 |
Issue: [% article_request.issue %] |
382 |
Issue: [% article_request.issue %] |
369 |
Date: [% article_request.date %] |
383 |
Date: [% article_request.date %] |
370 |
Pages: [% article_request.pages %] |
384 |
Pages: [% article_request.pages %] |
371 |
Chapters: [% article_request.chapters %] |
385 |
Chapters: [% article_request.chapters %] |
372 |
Notes: [% article_request.patron_notes %] |
386 |
Notes: [% article_request.patron_notes %] |
373 |
|; |
387 |
|; |
374 |
reset_template( { template => $tt_template, code => $code, module => 'circulation' } ); |
388 |
reset_template( { template => $tt_template, code => $code, module => 'circulation' } ); |
375 |
Koha::ArticleRequests->find( $article_request->{id} )->cancel; |
389 |
Koha::ArticleRequests->find( $article_request->{id} )->cancel; |
Lines 377-382
subtest 'regression tests' => sub {
Link Here
|
377 |
is( $tt_letter->content, $letter->content, 'Compare AR_* notices' ); |
391 |
is( $tt_letter->content, $letter->content, 'Compare AR_* notices' ); |
378 |
isnt( $tt_letter->message_id, $letter->message_id, 'Comparing AR_* notices should compare 2 different messages' ); |
392 |
isnt( $tt_letter->message_id, $letter->message_id, 'Comparing AR_* notices should compare 2 different messages' ); |
379 |
}; |
393 |
}; |
|
|
394 |
|
395 |
subtest 'CHECKOUT+CHECKIN' => sub { |
396 |
plan tests => 4; |
397 |
|
398 |
my $checkout_code = 'CHECKOUT'; |
399 |
my $checkin_code = 'CHECKIN'; |
400 |
|
401 |
my $dbh = C4::Context->dbh; |
402 |
# Enable notification for CHECKOUT - Things are hardcoded here but should work with default data |
403 |
$dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 6 ); |
404 |
my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
405 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
406 |
# Enable notification for CHECKIN - Things are hardcoded here but should work with default data |
407 |
$dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 5 ); |
408 |
$borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); |
409 |
$dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); |
410 |
|
411 |
# historic syntax |
412 |
my $checkout_template = q| |
413 |
The following items have been checked out: |
414 |
---- |
415 |
<<biblio.title>> |
416 |
---- |
417 |
Thank you for visiting <<branches.branchname>>. |
418 |
|; |
419 |
reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } ); |
420 |
my $checkin_template = q| |
421 |
The following items have been checkin out: |
422 |
---- |
423 |
<<biblio.title>> |
424 |
---- |
425 |
Thank you for visiting <<branches.branchname>>. |
426 |
|; |
427 |
reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } ); |
428 |
|
429 |
C4::Circulation::AddIssue( $patron, $item1->{barcode} ); |
430 |
my $first_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
431 |
C4::Circulation::AddIssue( $patron, $item2->{barcode} ); |
432 |
my $second_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
433 |
|
434 |
AddReturn( $item1->{barcode} ); |
435 |
my $first_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
436 |
AddReturn( $item2->{barcode} ); |
437 |
my $second_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
438 |
|
439 |
Koha::Notice::Messages->delete; |
440 |
|
441 |
# TT syntax |
442 |
$checkout_template = q| |
443 |
The following items have been checked out: |
444 |
---- |
445 |
[% biblio.title %] |
446 |
---- |
447 |
Thank you for visiting [% branch.branchname %]. |
448 |
|; |
449 |
reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } ); |
450 |
$checkin_template = q| |
451 |
The following items have been checkin out: |
452 |
---- |
453 |
[% biblio.title %] |
454 |
---- |
455 |
Thank you for visiting [% branch.branchname %]. |
456 |
|; |
457 |
reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } ); |
458 |
|
459 |
C4::Circulation::AddIssue( $patron, $item1->{barcode} ); |
460 |
my $first_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
461 |
C4::Circulation::AddIssue( $patron, $item2->{barcode} ); |
462 |
my $second_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
463 |
|
464 |
AddReturn( $item1->{barcode} ); |
465 |
my $first_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
466 |
AddReturn( $item2->{barcode} ); |
467 |
my $second_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; |
468 |
|
469 |
is( $first_checkout_tt_letter->content, $first_checkout_letter->content, ); |
470 |
is( $second_checkout_tt_letter->content, $second_checkout_letter->content, ); |
471 |
is( $first_checkin_tt_letter->content, $first_checkin_letter->content, ); |
472 |
is( $second_checkin_tt_letter->content, $second_checkin_letter->content, ); |
473 |
|
474 |
}; |
380 |
}; |
475 |
}; |
381 |
|
476 |
|
382 |
subtest 'loops' => sub { |
477 |
subtest 'loops' => sub { |
383 |
- |
|
|