|
Lines 7871-7877
subtest 'ChildNeedsGuarantor' => sub {
Link Here
|
| 7871 |
}; |
7871 |
}; |
| 7872 |
|
7872 |
|
| 7873 |
subtest 'Bug 9762: AddIssue override JSON logging' => sub { |
7873 |
subtest 'Bug 9762: AddIssue override JSON logging' => sub { |
| 7874 |
plan tests => 8; |
7874 |
plan tests => 11; |
| 7875 |
|
7875 |
|
| 7876 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
7876 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 7877 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
7877 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
Lines 7883-7889
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 7883 |
# Clear any existing logs |
7883 |
# Clear any existing logs |
| 7884 |
Koha::ActionLogs->search( { module => 'CIRCULATION', action => 'ISSUE' } )->delete; |
7884 |
Koha::ActionLogs->search( { module => 'CIRCULATION', action => 'ISSUE' } )->delete; |
| 7885 |
|
7885 |
|
| 7886 |
# Test 1: Normal checkout without overrides - should log item number only |
7886 |
# Test 1: Normal checkout without overrides - should log JSON with empty arrays |
| 7887 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
7887 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode ); |
| 7888 |
ok( $issue, 'Item checked out successfully' ); |
7888 |
ok( $issue, 'Item checked out successfully' ); |
| 7889 |
|
7889 |
|
|
Lines 7896-7903
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 7896 |
{ order_by => { -desc => 'timestamp' } } |
7896 |
{ order_by => { -desc => 'timestamp' } } |
| 7897 |
); |
7897 |
); |
| 7898 |
is( $logs->count, 1, 'One log entry created for normal checkout' ); |
7898 |
is( $logs->count, 1, 'One log entry created for normal checkout' ); |
| 7899 |
my $log = $logs->next; |
7899 |
my $log = $logs->next; |
| 7900 |
is( $log->info, $item->itemnumber, 'Normal checkout logs item number only' ); |
7900 |
my $log_data = eval { from_json( $log->info ) }; |
|
|
7901 |
ok( !$@, 'Normal checkout log info is valid JSON' ); |
| 7902 |
is( $log_data->{itemnumber}, $item->itemnumber, 'JSON contains correct itemnumber' ); |
| 7903 |
is_deeply( $log_data->{confirmations}, [], 'Confirmations is empty array for normal checkout' ); |
| 7904 |
is_deeply( $log_data->{forced}, [], 'Forced is empty array for normal checkout' ); |
| 7901 |
|
7905 |
|
| 7902 |
# Return the item for next test |
7906 |
# Return the item for next test |
| 7903 |
C4::Circulation::AddReturn( $item->barcode, $library->branchcode ); |
7907 |
C4::Circulation::AddReturn( $item->barcode, $library->branchcode ); |
|
Lines 7921-7934
subtest 'Bug 9762: AddIssue override JSON logging' => sub {
Link Here
|
| 7921 |
module => 'CIRCULATION', |
7925 |
module => 'CIRCULATION', |
| 7922 |
action => 'ISSUE', |
7926 |
action => 'ISSUE', |
| 7923 |
object => $patron->borrowernumber, |
7927 |
object => $patron->borrowernumber, |
| 7924 |
info => { '!=', $item->itemnumber } # Exclude the first test log |
7928 |
info => { 'LIKE', '%' . $item2->itemnumber . '%' } # Find the second test log by itemnumber |
| 7925 |
}, |
7929 |
}, |
| 7926 |
{ order_by => { -desc => 'timestamp' } } |
7930 |
{ order_by => { -desc => 'timestamp' } } |
| 7927 |
); |
7931 |
); |
| 7928 |
is( $logs->count, 1, 'One log entry created for override checkout' ); |
7932 |
is( $logs->count, 1, 'One log entry created for override checkout' ); |
| 7929 |
$log = $logs->next; |
7933 |
$log = $logs->next; |
| 7930 |
|
7934 |
|
| 7931 |
my $log_data = eval { from_json( $log->info ) }; |
7935 |
$log_data = eval { from_json( $log->info ) }; |
| 7932 |
ok( !$@, 'Log info is valid JSON' ); |
7936 |
ok( !$@, 'Log info is valid JSON' ); |
| 7933 |
ok( exists $log_data->{confirmations}, 'JSON contains confirmations array' ); |
7937 |
ok( exists $log_data->{confirmations}, 'JSON contains confirmations array' ); |
| 7934 |
is_deeply( $log_data->{confirmations}, [ 'DEBT', 'AGE_RESTRICTION' ], 'Confirmations logged correctly' ); |
7938 |
is_deeply( $log_data->{confirmations}, [ 'DEBT', 'AGE_RESTRICTION' ], 'Confirmations logged correctly' ); |
| 7935 |
- |
|
|