Lines 409-415
subtest 'merge_and_replace_with' => sub {
Link Here
|
409 |
}; |
409 |
}; |
410 |
|
410 |
|
411 |
subtest 'action log tests' => sub { |
411 |
subtest 'action log tests' => sub { |
412 |
plan tests => 9; |
412 |
plan tests => 11; |
413 |
my $schema = Koha::Database->new->schema; |
413 |
my $schema = Koha::Database->new->schema; |
414 |
$schema->storage->txn_begin; |
414 |
$schema->storage->txn_begin; |
415 |
|
415 |
|
Lines 421-427
subtest 'action log tests' => sub {
Link Here
|
421 |
}; |
421 |
}; |
422 |
if ($repeatable) { |
422 |
if ($repeatable) { |
423 |
while (my ($k, $v) = each %{$change}) { |
423 |
while (my ($k, $v) = each %{$change}) { |
424 |
$change->{$k} = $v ? [$v] : []; |
424 |
if (ref $v eq 'ARRAY') { |
|
|
425 |
$change->{$k} = [sort @{$v}]; |
426 |
} |
427 |
else { |
428 |
$change->{$k} = $v ? [$v] : []; |
429 |
} |
425 |
} |
430 |
} |
426 |
} |
431 |
} |
427 |
return "Patron attribute " . $code . ": " . to_json($change, { pretty => 1, canonical => 1 }); |
432 |
return "Patron attribute " . $code . ": " . to_json($change, { pretty => 1, canonical => 1 }); |
Lines 557-562
subtest 'action log tests' => sub {
Link Here
|
557 |
); |
562 |
); |
558 |
} |
563 |
} |
559 |
|
564 |
|
|
|
565 |
$attributes = [ |
566 |
{ |
567 |
attribute => 'Foo', |
568 |
code => $attribute_type->code, |
569 |
}, |
570 |
{ |
571 |
attribute => 'Bar', |
572 |
code => $attribute_type->code, |
573 |
} |
574 |
]; |
575 |
$patron->extended_attributes($attributes); |
576 |
|
577 |
$info = $get_info->([], ['Foo', 'Bar'], $attribute_type->code, 1); |
578 |
use Data::Dumper; |
579 |
print Dumper($info); |
580 |
$action_logs = Koha::ActionLogs->search( |
581 |
{ |
582 |
module => "MEMBERS", |
583 |
action => "MODIFY", |
584 |
object => $patron->borrowernumber, |
585 |
info => $info |
586 |
} |
587 |
); |
588 |
is( |
589 |
$action_logs->count, |
590 |
1, |
591 |
"New action log entry has been created when updating repeatable patron attribute with multiple values" |
592 |
); |
593 |
|
594 |
$attributes = [ |
595 |
{ |
596 |
attribute => 'Foo', |
597 |
code => $attribute_type->code, |
598 |
}, |
599 |
{ |
600 |
attribute => 'Bar', |
601 |
code => $attribute_type->code, |
602 |
}, |
603 |
{ |
604 |
attribute => 'Baz', |
605 |
code => $attribute_type->code, |
606 |
} |
607 |
]; |
608 |
$patron->extended_attributes($attributes); |
609 |
|
610 |
$info = $get_info->( |
611 |
['Foo', 'Bar'], |
612 |
['Foo', 'Bar', 'Baz'], |
613 |
$attribute_type->code, |
614 |
1 |
615 |
); |
616 |
$action_logs = Koha::ActionLogs->search( |
617 |
{ |
618 |
module => "MEMBERS", |
619 |
action => "MODIFY", |
620 |
object => $patron->borrowernumber, |
621 |
info => $info |
622 |
} |
623 |
); |
624 |
is( |
625 |
$action_logs->count, |
626 |
1, |
627 |
"New action log entry has been created when updating repeatable patron attribute with existing multiple values with multiple values" |
628 |
); |
629 |
|
560 |
$schema->storage->txn_rollback; |
630 |
$schema->storage->txn_rollback; |
561 |
}; |
631 |
}; |
562 |
|
632 |
|
563 |
- |
|
|