|
Lines 8295-8301
subtest 'ChildNeedsGuarantor' => sub {
Link Here
|
| 8295 |
}; |
8295 |
}; |
| 8296 |
|
8296 |
|
| 8297 |
subtest 'Bug 9762: AddIssue override JSON logging' => sub { |
8297 |
subtest 'Bug 9762: AddIssue override JSON logging' => sub { |
| 8298 |
plan tests => 8; |
8298 |
plan tests => 11; |
| 8299 |
|
8299 |
|
| 8300 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
8300 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 8301 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
8301 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
Lines 8307-8313
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 8307 |
# Clear any existing logs |
8307 |
# Clear any existing logs |
| 8308 |
Koha::ActionLogs->search( { module => 'CIRCULATION', action => 'ISSUE' } )->delete; |
8308 |
Koha::ActionLogs->search( { module => 'CIRCULATION', action => 'ISSUE' } )->delete; |
| 8309 |
|
8309 |
|
| 8310 |
# Test 1: Normal checkout without overrides - should log item number only |
8310 |
# Test 1: Normal checkout without overrides - should log JSON with empty arrays |
| 8311 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
8311 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
| 8312 |
ok( $issue, 'Item checked out successfully' ); |
8312 |
ok( $issue, 'Item checked out successfully' ); |
| 8313 |
|
8313 |
|
|
Lines 8320-8327
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 8320 |
{ order_by => { -desc => 'timestamp' } } |
8320 |
{ order_by => { -desc => 'timestamp' } } |
| 8321 |
); |
8321 |
); |
| 8322 |
is( $logs->count, 1, 'One log entry created for normal checkout' ); |
8322 |
is( $logs->count, 1, 'One log entry created for normal checkout' ); |
| 8323 |
my $log = $logs->next; |
8323 |
my $log = $logs->next; |
| 8324 |
is( $log->info, $item->itemnumber, 'Normal checkout logs item number only' ); |
8324 |
my $log_data = eval { from_json( $log->info ) }; |
|
|
8325 |
ok( !$@, 'Normal checkout log info is valid JSON' ); |
| 8326 |
is( $log_data->{itemnumber}, $item->itemnumber, 'JSON contains correct itemnumber' ); |
| 8327 |
is_deeply( $log_data->{confirmations}, [], 'Confirmations is empty array for normal checkout' ); |
| 8328 |
is_deeply( $log_data->{forced}, [], 'Forced is empty array for normal checkout' ); |
| 8325 |
|
8329 |
|
| 8326 |
# Return the item for next test |
8330 |
# Return the item for next test |
| 8327 |
C4::Circulation::AddReturn( $item->barcode, $library->branchcode ); |
8331 |
C4::Circulation::AddReturn( $item->barcode, $library->branchcode ); |
|
Lines 8345-8358
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 8345 |
module => 'CIRCULATION', |
8349 |
module => 'CIRCULATION', |
| 8346 |
action => 'ISSUE', |
8350 |
action => 'ISSUE', |
| 8347 |
object => $patron->borrowernumber, |
8351 |
object => $patron->borrowernumber, |
| 8348 |
info => { '!=', $item->itemnumber } # Exclude the first test log |
8352 |
info => { 'LIKE', '%' . $item2->itemnumber . '%' } # Find the second test log by itemnumber |
| 8349 |
}, |
8353 |
}, |
| 8350 |
{ order_by => { -desc => 'timestamp' } } |
8354 |
{ order_by => { -desc => 'timestamp' } } |
| 8351 |
); |
8355 |
); |
| 8352 |
is( $logs->count, 1, 'One log entry created for override checkout' ); |
8356 |
is( $logs->count, 1, 'One log entry created for override checkout' ); |
| 8353 |
$log = $logs->next; |
8357 |
$log = $logs->next; |
| 8354 |
|
8358 |
|
| 8355 |
my $log_data = eval { from_json( $log->info ) }; |
8359 |
$log_data = eval { from_json( $log->info ) }; |
| 8356 |
ok( !$@, 'Log info is valid JSON' ); |
8360 |
ok( !$@, 'Log info is valid JSON' ); |
| 8357 |
ok( exists $log_data->{confirmations}, 'JSON contains confirmations array' ); |
8361 |
ok( exists $log_data->{confirmations}, 'JSON contains confirmations array' ); |
| 8358 |
is_deeply( $log_data->{confirmations}, [ 'DEBT', 'AGE_RESTRICTION' ], 'Confirmations logged correctly' ); |
8362 |
is_deeply( $log_data->{confirmations}, [ 'DEBT', 'AGE_RESTRICTION' ], 'Confirmations logged correctly' ); |
| 8359 |
- |
|
|