@@ -, +, @@ --- t/db_dependent/Koha/Patron/Attribute.t | 74 +++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) --- a/t/db_dependent/Koha/Patron/Attribute.t +++ a/t/db_dependent/Koha/Patron/Attribute.t @@ -409,7 +409,7 @@ subtest 'merge_and_replace_with' => sub { }; subtest 'action log tests' => sub { - plan tests => 9; + plan tests => 11; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -421,7 +421,12 @@ subtest 'action log tests' => sub { }; if ($repeatable) { while (my ($k, $v) = each %{$change}) { - $change->{$k} = $v ? [$v] : []; + if (ref $v eq 'ARRAY') { + $change->{$k} = [sort @{$v}]; + } + else { + $change->{$k} = $v ? [$v] : []; + } } } return "Patron attribute " . $code . ": " . to_json($change, { pretty => 1, canonical => 1 }); @@ -557,6 +562,71 @@ subtest 'action log tests' => sub { ); } + $attributes = [ + { + attribute => 'Foo', + code => $attribute_type->code, + }, + { + attribute => 'Bar', + code => $attribute_type->code, + } + ]; + $patron->extended_attributes($attributes); + + $info = $get_info->([], ['Foo', 'Bar'], $attribute_type->code, 1); + use Data::Dumper; + print Dumper($info); + $action_logs = Koha::ActionLogs->search( + { + module => "MEMBERS", + action => "MODIFY", + object => $patron->borrowernumber, + info => $info + } + ); + is( + $action_logs->count, + 1, + "New action log entry has been created when updating repeatable patron attribute with multiple values" + ); + + $attributes = [ + { + attribute => 'Foo', + code => $attribute_type->code, + }, + { + attribute => 'Bar', + code => $attribute_type->code, + }, + { + attribute => 'Baz', + code => $attribute_type->code, + } + ]; + $patron->extended_attributes($attributes); + + $info = $get_info->( + ['Foo', 'Bar'], + ['Foo', 'Bar', 'Baz'], + $attribute_type->code, + 1 + ); + $action_logs = Koha::ActionLogs->search( + { + module => "MEMBERS", + action => "MODIFY", + object => $patron->borrowernumber, + info => $info + } + ); + is( + $action_logs->count, + 1, + "New action log entry has been created when updating repeatable patron attribute with existing multiple values with multiple values" + ); + $schema->storage->txn_rollback; }; --