|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 77; |
20 |
use Test::More tests => 78; |
| 21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 1406-1411
subtest 'ModReserveAffect logging' => sub {
Link Here
|
| 1406 |
like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); |
1406 |
like( $log->info, qr{$expected}, 'Timestamp logged is the current one' ); |
| 1407 |
}; |
1407 |
}; |
| 1408 |
|
1408 |
|
|
|
1409 |
subtest 'ModReserve logging' => sub { |
| 1410 |
|
| 1411 |
plan tests => 2; |
| 1412 |
|
| 1413 |
t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); |
| 1414 |
|
| 1415 |
my $item = $builder->build_sample_item; |
| 1416 |
my $patron = $builder->build_object( |
| 1417 |
{ |
| 1418 |
class => "Koha::Patrons", |
| 1419 |
value => { branchcode => $item->homebranch } |
| 1420 |
} |
| 1421 |
); |
| 1422 |
|
| 1423 |
my $hold1 = $builder->build_object( |
| 1424 |
{ |
| 1425 |
class => "Koha::Holds", |
| 1426 |
value => { |
| 1427 |
found => "W", |
| 1428 |
priority => 0, |
| 1429 |
itemnumber => undef, |
| 1430 |
biblionumber => $item->biblionumber, |
| 1431 |
waitingdate => undef, |
| 1432 |
cancellationdate => undef, |
| 1433 |
item_level_hold => 0, |
| 1434 |
lowestPriority => 0, |
| 1435 |
expirationdate => '2022-12-24', |
| 1436 |
suspend_until => undef, |
| 1437 |
suspend => 0, |
| 1438 |
itemtype => undef, |
| 1439 |
borrowernumber => $patron->borrowernumber |
| 1440 |
} |
| 1441 |
} |
| 1442 |
); |
| 1443 |
|
| 1444 |
my $other_branch = $builder->build_object( { class => "Koha::Libraries" } ); |
| 1445 |
|
| 1446 |
# Test changing expiration date |
| 1447 |
my $params = { |
| 1448 |
rank => $hold1->priority, |
| 1449 |
reserve_id => $hold1->reserve_id, |
| 1450 |
biblionumber => $item->biblionumber, |
| 1451 |
borrowernumber => $patron->borrowernumber, |
| 1452 |
branchcode => $hold1->branchcode, |
| 1453 |
expirationdate => "2022-12-31", |
| 1454 |
}; |
| 1455 |
|
| 1456 |
ModReserve($params); |
| 1457 |
my $log = Koha::ActionLogs->search( |
| 1458 |
{ module => 'HOLDS', action => 'MODIFY', object => $hold1->reserve_id } |
| 1459 |
)->next; |
| 1460 |
my $expected = sprintf q{'expirationdate' => '%s'}, |
| 1461 |
$params->{expirationdate}; |
| 1462 |
like( $log->info, qr{$expected}, |
| 1463 |
'Expiration date should have changed in logs' ); |
| 1464 |
|
| 1465 |
# Test making other changes |
| 1466 |
my $hold2 = $builder->build_object( |
| 1467 |
{ |
| 1468 |
class => "Koha::Holds", |
| 1469 |
value => { |
| 1470 |
found => undef, |
| 1471 |
priority => 1, |
| 1472 |
itemnumber => undef, |
| 1473 |
biblionumber => $item->biblionumber, |
| 1474 |
waitingdate => undef, |
| 1475 |
cancellationdate => undef, |
| 1476 |
item_level_hold => 0, |
| 1477 |
lowestPriority => 0, |
| 1478 |
expirationdate => '2022-12-24', |
| 1479 |
suspend_until => undef, |
| 1480 |
suspend => 0, |
| 1481 |
itemtype => undef, |
| 1482 |
borrowernumber => $patron->borrowernumber |
| 1483 |
} |
| 1484 |
} |
| 1485 |
); |
| 1486 |
|
| 1487 |
$params = { |
| 1488 |
rank => $hold2->priority, |
| 1489 |
reserve_id => $hold2->reserve_id, |
| 1490 |
biblionumber => $item->biblionumber, |
| 1491 |
borrowernumber => $patron->borrowernumber, |
| 1492 |
branchcode => $other_branch->branchcode, |
| 1493 |
}; |
| 1494 |
|
| 1495 |
ModReserve($params); |
| 1496 |
$log = Koha::ActionLogs->search( |
| 1497 |
{ module => 'HOLDS', action => 'MODIFY', object => $hold2->reserve_id } |
| 1498 |
)->next; |
| 1499 |
$expected = sprintf q{'branchcode' => '%s'}, $other_branch->branchcode; |
| 1500 |
like( $log->info, qr{$expected}, 'Branchcode should have changed in logs' ); |
| 1501 |
|
| 1502 |
}; |
| 1503 |
|
| 1409 |
sub count_hold_print_messages { |
1504 |
sub count_hold_print_messages { |
| 1410 |
my $message_count = $dbh->selectall_arrayref(q{ |
1505 |
my $message_count = $dbh->selectall_arrayref(q{ |
| 1411 |
SELECT COUNT(*) |
1506 |
SELECT COUNT(*) |
| 1412 |
- |
|
|