Lines 25-30
use Test::More tests => 2;
Link Here
|
25 |
use Test::Exception; |
25 |
use Test::Exception; |
26 |
|
26 |
|
27 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
use Koha::DateUtils qw( dt_from_string ); |
|
|
28 |
use Koha::Notice::Template; |
29 |
use Koha::Notice::Templates; |
28 |
|
30 |
|
29 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
30 |
use t::lib::Mocks; |
32 |
use t::lib::Mocks; |
Lines 341-348
subtest 'store() tests' => sub {
Link Here
|
341 |
# Cancel both bookings so we can check that cancelled bookings are allowed in the auto-assign |
343 |
# Cancel both bookings so we can check that cancelled bookings are allowed in the auto-assign |
342 |
$booking->status('cancelled')->store(); |
344 |
$booking->status('cancelled')->store(); |
343 |
$second_booking->status('cancelled')->store(); |
345 |
$second_booking->status('cancelled')->store(); |
344 |
is($booking->status, 'cancelled', "Booking is cancelled"); |
346 |
is( $booking->status, 'cancelled', "Booking is cancelled" ); |
345 |
is($second_booking->status, 'cancelled', "Second booking is cancelled"); |
347 |
is( $second_booking->status, 'cancelled', "Second booking is cancelled" ); |
346 |
|
348 |
|
347 |
# Test randomness of selection |
349 |
# Test randomness of selection |
348 |
my %seen_items; |
350 |
my %seen_items; |
Lines 369-374
subtest 'store() tests' => sub {
Link Here
|
369 |
subtest 'confirmation notice trigger' => sub { |
371 |
subtest 'confirmation notice trigger' => sub { |
370 |
plan tests => 2; |
372 |
plan tests => 2; |
371 |
|
373 |
|
|
|
374 |
# FIXME: This is a bandaid solution to prevent test failures when running |
375 |
# the Koha_Main_My8 job because notices are not added at upgrade time. |
376 |
my $template = Koha::Notice::Templates->search( |
377 |
{ |
378 |
module => 'bookings', |
379 |
code => 'BOOKING_CONFIRMATION', |
380 |
message_transport_type => 'email', |
381 |
} |
382 |
)->single; |
383 |
|
384 |
if ( !$template ) { |
385 |
my $default_content = Koha::Notice::Template->new( |
386 |
{ |
387 |
module => 'bookings', |
388 |
code => 'BOOKING_CONFIRMATION', |
389 |
lang => 'default', |
390 |
message_transport_type => 'email', |
391 |
} |
392 |
)->get_default(); |
393 |
|
394 |
Koha::Notice::Template->new( |
395 |
{ |
396 |
module => 'bookings', |
397 |
code => 'BOOKING_CONFIRMATION', |
398 |
name => 'BOOKING_CONFIRMATION Test Notice', |
399 |
title => 'BOOKING_CONFIRMATION Test Notice', |
400 |
content => $default_content || 'Dummy content for BOOKING_CONFIRMATION.', |
401 |
branchcode => undef, |
402 |
message_transport_type => 'email', |
403 |
} |
404 |
)->store; |
405 |
} |
406 |
|
372 |
my $original_notices_count = Koha::Notice::Messages->search( |
407 |
my $original_notices_count = Koha::Notice::Messages->search( |
373 |
{ |
408 |
{ |
374 |
letter_code => 'BOOKING_CONFIRMATION', |
409 |
letter_code => 'BOOKING_CONFIRMATION', |
Lines 420-425
subtest 'store() tests' => sub {
Link Here
|
420 |
subtest 'modification/cancellation notice triggers' => sub { |
455 |
subtest 'modification/cancellation notice triggers' => sub { |
421 |
plan tests => 5; |
456 |
plan tests => 5; |
422 |
|
457 |
|
|
|
458 |
# FIXME: This is a bandaid solution to prevent test failures when running |
459 |
# the Koha_Main_My8 job because notices are not added at upgrade time. |
460 |
for my $notice_type (qw(BOOKING_MODIFICATION BOOKING_CANCELLATION)) { |
461 |
my $template = Koha::Notice::Templates->search( |
462 |
{ |
463 |
module => 'bookings', |
464 |
code => $notice_type, |
465 |
message_transport_type => 'email', |
466 |
} |
467 |
)->single; |
468 |
|
469 |
if ( !$template ) { |
470 |
my $default_content = Koha::Notice::Template->new( |
471 |
{ |
472 |
module => 'bookings', |
473 |
code => $notice_type, |
474 |
lang => 'default', |
475 |
message_transport_type => 'email', |
476 |
} |
477 |
)->get_default(); |
478 |
|
479 |
Koha::Notice::Template->new( |
480 |
{ |
481 |
module => 'bookings', |
482 |
code => $notice_type, |
483 |
name => "$notice_type Test Notice", |
484 |
title => "$notice_type Test Notice", |
485 |
content => $default_content || "Dummy content for $notice_type.", |
486 |
branchcode => undef, |
487 |
message_transport_type => 'email', |
488 |
} |
489 |
)->store; |
490 |
} |
491 |
} |
492 |
|
423 |
my $original_modification_notices_count = Koha::Notice::Messages->search( |
493 |
my $original_modification_notices_count = Koha::Notice::Messages->search( |
424 |
{ |
494 |
{ |
425 |
letter_code => 'BOOKING_MODIFICATION', |
495 |
letter_code => 'BOOKING_MODIFICATION', |
Lines 556-558
subtest 'store() tests' => sub {
Link Here
|
556 |
|
626 |
|
557 |
$schema->storage->txn_rollback; |
627 |
$schema->storage->txn_rollback; |
558 |
}; |
628 |
}; |
559 |
- |
629 |
|