Lines 18-25
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
use JSON qw( to_json ); |
21 |
|
22 |
|
22 |
use Test::More tests => 3; |
23 |
use Test::More tests => 4; |
23 |
|
24 |
|
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
25 |
use Test::Exception; |
26 |
use Test::Exception; |
Lines 27-32
use Test::Exception;
Link Here
|
27 |
use Koha::Database; |
28 |
use Koha::Database; |
28 |
use Koha::Patron::Attribute; |
29 |
use Koha::Patron::Attribute; |
29 |
use Koha::Patron::Attributes; |
30 |
use Koha::Patron::Attributes; |
|
|
31 |
use Koha::ActionLogs; |
30 |
|
32 |
|
31 |
my $schema = Koha::Database->new->schema; |
33 |
my $schema = Koha::Database->new->schema; |
32 |
my $builder = t::lib::TestBuilder->new; |
34 |
my $builder = t::lib::TestBuilder->new; |
Lines 404-406
subtest 'merge_and_replace_with' => sub {
Link Here
|
404 |
$schema->storage->txn_rollback; |
406 |
$schema->storage->txn_rollback; |
405 |
|
407 |
|
406 |
}; |
408 |
}; |
407 |
- |
409 |
|
|
|
410 |
subtest 'action log tests' => sub { |
411 |
plan tests => 3; |
412 |
my $schema = Koha::Database->new->schema; |
413 |
$schema->storage->txn_begin; |
414 |
|
415 |
my $patron = $builder->build_object({ class=> 'Koha::Patrons' }); |
416 |
my $attribute_type = $builder->build_object( |
417 |
{ |
418 |
class => 'Koha::Patron::Attribute::Types', |
419 |
value => { repeatable => 0 } |
420 |
} |
421 |
); |
422 |
|
423 |
my $attributes = [ |
424 |
{ |
425 |
attribute => 'Foo', |
426 |
code => $attribute_type->code, |
427 |
} |
428 |
]; |
429 |
$patron->extended_attributes($attributes); |
430 |
|
431 |
my $change = { |
432 |
before => "", |
433 |
after => 'Foo', |
434 |
}; |
435 |
my $info = "Patron attribute " . $attribute_type->code . ": " . to_json($change, { pretty => 1, canonical => 1 }); |
436 |
my $action_logs = Koha::ActionLogs->search( |
437 |
{ |
438 |
module => "MEMBERS", |
439 |
action => "MODIFY", |
440 |
object => $patron->borrowernumber, |
441 |
info => $info |
442 |
} |
443 |
); |
444 |
is( |
445 |
$action_logs->count, |
446 |
1, |
447 |
'An action log entry has been created when adding patron attribute' |
448 |
); |
449 |
|
450 |
$patron->extended_attributes($attributes); |
451 |
$action_logs = Koha::ActionLogs->search( |
452 |
{ |
453 |
module => "MEMBERS", |
454 |
action => "MODIFY", |
455 |
object => $patron->borrowernumber, |
456 |
info => $info |
457 |
} |
458 |
); |
459 |
is( |
460 |
$action_logs->count, |
461 |
1, |
462 |
'No additional action log entry has been created when updating patron attribute with same value' |
463 |
); |
464 |
|
465 |
$attributes = [ |
466 |
{ |
467 |
attribute => 'Bar', |
468 |
code => $attribute_type->code, |
469 |
} |
470 |
]; |
471 |
$patron->extended_attributes($attributes); |
472 |
|
473 |
$change = { |
474 |
before => 'Foo', |
475 |
after => 'Bar' |
476 |
}; |
477 |
$info = "Patron attribute " . $attribute_type->code . ": " . to_json($change, { pretty => 1, canonical => 1 }); |
478 |
$action_logs = Koha::ActionLogs->search( |
479 |
{ |
480 |
module => "MEMBERS", |
481 |
action => "MODIFY", |
482 |
object => $patron->borrowernumber, |
483 |
info => $info |
484 |
} |
485 |
); |
486 |
is( |
487 |
$action_logs->count, |
488 |
1, |
489 |
'New action log entry has been created when updating patron attribute with different value' |
490 |
); |
491 |
|
492 |
$schema->storage->txn_rollback; |
493 |
}; |
494 |
|