|
Lines 18-28
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::NoWarnings; |
20 |
use Test::NoWarnings; |
| 21 |
use Test::More tests => 41; |
21 |
use Test::More tests => 42; |
| 22 |
use Test::Exception; |
22 |
use Test::Exception; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
| 25 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
25 |
use C4::Biblio qw( AddBiblio DelBiblio ModBiblio ModBiblioMarc ); |
| 26 |
use C4::Circulation qw( AddIssue AddReturn ); |
26 |
use C4::Circulation qw( AddIssue AddReturn ); |
| 27 |
use C4::Reserves qw( AddReserve ); |
27 |
use C4::Reserves qw( AddReserve ); |
| 28 |
|
28 |
|
|
Lines 34-41
use Koha::Acquisition::Orders;
Link Here
|
| 34 |
use Koha::AuthorisedValueCategories; |
34 |
use Koha::AuthorisedValueCategories; |
| 35 |
use Koha::AuthorisedValues; |
35 |
use Koha::AuthorisedValues; |
| 36 |
use Koha::MarcSubfieldStructures; |
36 |
use Koha::MarcSubfieldStructures; |
|
|
37 |
use Koha::ActionLogs; |
| 37 |
use Koha::Exception; |
38 |
use Koha::Exception; |
| 38 |
|
39 |
|
|
|
40 |
use JSON qw( decode_json ); |
| 41 |
|
| 39 |
use MARC::Field; |
42 |
use MARC::Field; |
| 40 |
use MARC::Record; |
43 |
use MARC::Record; |
| 41 |
|
44 |
|
|
Lines 2441-2443
subtest 'check_booking tests' => sub {
Link Here
|
| 2441 |
|
2444 |
|
| 2442 |
$schema->storage->txn_rollback; |
2445 |
$schema->storage->txn_rollback; |
| 2443 |
}; |
2446 |
}; |
| 2444 |
- |
2447 |
|
|
|
2448 |
subtest '_unblessed_for_log() tests' => sub { |
| 2449 |
|
| 2450 |
plan tests => 10; |
| 2451 |
|
| 2452 |
$schema->storage->txn_begin; |
| 2453 |
|
| 2454 |
# Build a biblio where several nullable columns are undef |
| 2455 |
my $biblio = $builder->build_sample_biblio( { author => 'Test Author', title => 'Test Title' } ); |
| 2456 |
|
| 2457 |
# Force some nullable columns to undef/empty |
| 2458 |
$biblio->set( { abstract => undef, notes => '', seriestitle => undef } )->store; |
| 2459 |
$biblio->discard_changes; |
| 2460 |
|
| 2461 |
my $data = $biblio->_unblessed_for_log; |
| 2462 |
|
| 2463 |
ok( ref $data eq 'HASH', '_unblessed_for_log returns a hashref' ); |
| 2464 |
ok( exists $data->{biblionumber}, 'biblionumber is present' ); |
| 2465 |
ok( exists $data->{title}, 'title (set value) is present' ); |
| 2466 |
ok( exists $data->{author}, 'author (set value) is present' ); |
| 2467 |
ok( !exists $data->{timestamp}, 'timestamp is excluded' ); |
| 2468 |
ok( !exists $data->{abstract}, 'undef field (abstract) is excluded' ); |
| 2469 |
ok( !exists $data->{notes}, 'empty-string field (notes) is excluded' ); |
| 2470 |
ok( !exists $data->{seriestitle}, 'undef field (seriestitle) is excluded' ); |
| 2471 |
|
| 2472 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
| 2473 |
|
| 2474 |
# ADD log: diff should not contain timestamp |
| 2475 |
my $record = MARC::Record->new(); |
| 2476 |
$record->append_fields( MARC::Field->new( '245', '1', '0', 'a' => 'Log Test Title' ) ); |
| 2477 |
my ($new_biblionumber) = AddBiblio( $record, '' ); |
| 2478 |
|
| 2479 |
my $add_log = |
| 2480 |
Koha::ActionLogs->search( { object => $new_biblionumber, module => 'Cataloguing', action => 'ADD' } )->next; |
| 2481 |
ok( defined $add_log->diff, 'ADD log populates the diff column' ); |
| 2482 |
|
| 2483 |
my $add_diff = decode_json( $add_log->diff ); |
| 2484 |
my $diff_keys = exists $add_diff->{D} ? $add_diff->{D} : {}; |
| 2485 |
ok( !exists $diff_keys->{timestamp}, 'timestamp not present in ADD diff' ); |
| 2486 |
|
| 2487 |
$schema->storage->txn_rollback; |
| 2488 |
}; |