|
Lines 123-129
subtest 'Relation accessor tests' => sub {
Link Here
|
| 123 |
}; |
123 |
}; |
| 124 |
|
124 |
|
| 125 |
subtest 'store() tests' => sub { |
125 |
subtest 'store() tests' => sub { |
| 126 |
plan tests => 13; |
126 |
plan tests => 14; |
| 127 |
$schema->storage->txn_begin; |
127 |
$schema->storage->txn_begin; |
| 128 |
|
128 |
|
| 129 |
my $patron = $builder->build_object( { class => "Koha::Patrons" } ); |
129 |
my $patron = $builder->build_object( { class => "Koha::Patrons" } ); |
|
Lines 322-327
subtest 'store() tests' => sub {
Link Here
|
| 322 |
# ✓ Any (1) |--| |
322 |
# ✓ Any (1) |--| |
| 323 |
}; |
323 |
}; |
| 324 |
|
324 |
|
|
|
325 |
subtest 'notice trigger' => sub { |
| 326 |
plan tests => 3; |
| 327 |
|
| 328 |
my $original_notices_count = Koha::Notice::Messages->search( |
| 329 |
{ |
| 330 |
letter_code => 'BOOKING_MODIFICATION', |
| 331 |
borrowernumber => $patron->borrowernumber, |
| 332 |
} |
| 333 |
)->count; |
| 334 |
|
| 335 |
$start_1 = dt_from_string->add( months => 1 )->truncate( to => 'day' ); |
| 336 |
$end_1 = $start_1->clone()->add( days => 1 ); |
| 337 |
|
| 338 |
# Use datetime formatting so that we don't get DateTime objects |
| 339 |
$booking = Koha::Booking->new( |
| 340 |
{ |
| 341 |
patron_id => $patron->borrowernumber, |
| 342 |
biblio_id => $biblio->biblionumber, |
| 343 |
pickup_library_id => $item_2->homebranch, |
| 344 |
start_date => $start_1->datetime(q{ }), |
| 345 |
end_date => $end_1->datetime(q{ }), |
| 346 |
} |
| 347 |
)->store; |
| 348 |
|
| 349 |
my $post_notices_count = Koha::Notice::Messages->search( |
| 350 |
{ |
| 351 |
letter_code => 'BOOKING_MODIFICATION', |
| 352 |
borrowernumber => $patron->borrowernumber, |
| 353 |
} |
| 354 |
)->count; |
| 355 |
is( |
| 356 |
$post_notices_count, |
| 357 |
$original_notices_count, |
| 358 |
'Koha::Booking->store should not have enqueued a BOOKING_MODIFICATION email for a new booking' |
| 359 |
); |
| 360 |
|
| 361 |
my $item_4 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 1 } ); |
| 362 |
|
| 363 |
$booking->update( |
| 364 |
{ |
| 365 |
item_id => $item_4->itemnumber, |
| 366 |
} |
| 367 |
); |
| 368 |
|
| 369 |
$post_notices_count = Koha::Notice::Messages->search( |
| 370 |
{ |
| 371 |
letter_code => 'BOOKING_MODIFICATION', |
| 372 |
borrowernumber => $patron->borrowernumber, |
| 373 |
} |
| 374 |
)->count; |
| 375 |
is( |
| 376 |
$post_notices_count, |
| 377 |
$original_notices_count, |
| 378 |
'Koha::Booking->store should not have enqueued a BOOKING_MODIFICATION email for a booking with modified item_id' |
| 379 |
); |
| 380 |
|
| 381 |
$booking->update( |
| 382 |
{ |
| 383 |
start_date => $start_1->clone()->add( days => 1 )->datetime(q{ }), |
| 384 |
} |
| 385 |
); |
| 386 |
|
| 387 |
# start_date, end_date and pickup_library_id should behave identical |
| 388 |
$post_notices_count = Koha::Notice::Messages->search( |
| 389 |
{ |
| 390 |
letter_code => 'BOOKING_MODIFICATION', |
| 391 |
borrowernumber => $patron->borrowernumber, |
| 392 |
} |
| 393 |
)->count; |
| 394 |
is( |
| 395 |
$post_notices_count, |
| 396 |
$original_notices_count + 1, |
| 397 |
'Koha::Booking->store should have enqueued a BOOKING_MODIFICATION email for a booking with modified start_date' |
| 398 |
); |
| 399 |
|
| 400 |
$booking->update( |
| 401 |
{ |
| 402 |
end_date => $end_1->clone()->add( days => 1 )->datetime(q{ }), |
| 403 |
} |
| 404 |
); |
| 405 |
}; |
| 406 |
|
| 325 |
$schema->storage->txn_rollback; |
407 |
$schema->storage->txn_rollback; |
| 326 |
}; |
408 |
}; |
| 327 |
|
409 |
|
| 328 |
- |
|
|