|
Lines 20-29
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::NoWarnings; |
22 |
use Test::NoWarnings; |
| 23 |
use Test::More tests => 12; |
23 |
use Test::More tests => 13; |
| 24 |
use Test::Exception; |
24 |
use Test::Exception; |
| 25 |
use Test::Warn; |
25 |
use Test::Warn; |
| 26 |
|
26 |
|
|
|
27 |
use C4::Suggestions qw( DelSuggestion ); |
| 28 |
use Koha::ActionLogs; |
| 27 |
use Koha::Suggestions; |
29 |
use Koha::Suggestions; |
| 28 |
use Koha::Notice::Messages; |
30 |
use Koha::Notice::Messages; |
| 29 |
use Koha::Database; |
31 |
use Koha::Database; |
|
Lines 513-515
subtest 'filter_by_suggested_days_range() tests' => sub {
Link Here
|
| 513 |
|
515 |
|
| 514 |
$schema->storage->txn_rollback; |
516 |
$schema->storage->txn_rollback; |
| 515 |
}; |
517 |
}; |
| 516 |
- |
518 |
|
|
|
519 |
subtest 'Suggestion action logs populate the diff column' => sub { |
| 520 |
|
| 521 |
plan tests => 9; |
| 522 |
|
| 523 |
$schema->storage->txn_begin; |
| 524 |
|
| 525 |
t::lib::Mocks::mock_preference( 'SuggestionsLog', 1 ); |
| 526 |
|
| 527 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 528 |
|
| 529 |
# CREATE |
| 530 |
my $suggestion = Koha::Suggestion->new( |
| 531 |
{ |
| 532 |
suggestedby => $patron->borrowernumber, |
| 533 |
title => 'Test title', |
| 534 |
} |
| 535 |
)->store; |
| 536 |
my $suggestionid = $suggestion->suggestionid; |
| 537 |
|
| 538 |
my $create_log = |
| 539 |
Koha::ActionLogs->search( { module => 'SUGGESTION', action => 'CREATE', object => $suggestionid } )->single; |
| 540 |
ok( defined $create_log, 'CREATE log entry exists' ); |
| 541 |
ok( defined $create_log->diff, 'diff column is populated for CREATE' ); |
| 542 |
like( $create_log->diff, qr/title/, 'CREATE diff contains suggestion fields' ); |
| 543 |
|
| 544 |
# MODIFY |
| 545 |
$suggestion->title('Updated title')->store; |
| 546 |
|
| 547 |
my $modify_log = |
| 548 |
Koha::ActionLogs->search( { module => 'SUGGESTION', action => 'MODIFY', object => $suggestionid } )->single; |
| 549 |
ok( defined $modify_log, 'MODIFY log entry exists' ); |
| 550 |
ok( defined $modify_log->diff, 'diff column is populated for MODIFY' ); |
| 551 |
like( $modify_log->diff, qr/title/, 'MODIFY diff contains changed field' ); |
| 552 |
|
| 553 |
# DELETE via DelSuggestion |
| 554 |
C4::Suggestions::DelSuggestion( undef, $suggestionid, 'intranet' ); |
| 555 |
|
| 556 |
my $delete_log = |
| 557 |
Koha::ActionLogs->search( { module => 'SUGGESTION', action => 'DELETE', object => $suggestionid } )->single; |
| 558 |
ok( defined $delete_log, 'DELETE log entry exists' ); |
| 559 |
ok( defined $delete_log->diff, 'diff column is populated for DELETE' ); |
| 560 |
like( $delete_log->diff, qr/title/, 'DELETE diff contains suggestion fields' ); |
| 561 |
|
| 562 |
$schema->storage->txn_rollback; |
| 563 |
}; |