Bugzilla – Attachment 195199 Details for
Bug 40135
Record diff in action logs when modifying a bibliographic record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40135: (follow-up) Add tests for Koha::Biblio::_unblessed_for_log
ca54d7d.patch (text/plain), 3.53 KB, created by
Lisette Scheer
on 2026-03-12 16:20:39 UTC
(
hide
)
Description:
Bug 40135: (follow-up) Add tests for Koha::Biblio::_unblessed_for_log
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2026-03-12 16:20:39 UTC
Size:
3.53 KB
patch
obsolete
>From ca54d7da102571197b5312ec09701c11d72a0db4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Thu, 12 Mar 2026 10:51:09 +0000 >Subject: [PATCH] Bug 40135: (follow-up) Add tests for > Koha::Biblio::_unblessed_for_log > >Add a '_unblessed_for_log() tests' subtest to t/db_dependent/Koha/Biblio.t >that verifies: >- the method returns a plain hashref >- fields with real values (biblionumber, title, author) are present >- timestamp is excluded >- undef fields are excluded >- empty-string fields are excluded >- the ADD action log diff column is populated and does not contain timestamp > >Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> >--- > t/db_dependent/Koha/Biblio.t | 49 ++++++++++++++++++++++++++++++++++-- > 1 file changed, 47 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index 48b8c607c8b..068f0d3e029 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -18,11 +18,11 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 41; >+use Test::More tests => 42; > use Test::Exception; > use Test::Warn; > >-use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); >+use C4::Biblio qw( AddBiblio DelBiblio ModBiblio ModBiblioMarc ); > use C4::Circulation qw( AddIssue AddReturn ); > use C4::Reserves qw( AddReserve ); > >@@ -34,8 +34,11 @@ use Koha::Acquisition::Orders; > use Koha::AuthorisedValueCategories; > use Koha::AuthorisedValues; > use Koha::MarcSubfieldStructures; >+use Koha::ActionLogs; > use Koha::Exception; > >+use JSON qw( decode_json ); >+ > use MARC::Field; > use MARC::Record; > >@@ -2441,3 +2444,45 @@ subtest 'check_booking tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest '_unblessed_for_log() tests' => sub { >+ >+ plan tests => 10; >+ >+ $schema->storage->txn_begin; >+ >+ # Build a biblio where several nullable columns are undef >+ my $biblio = $builder->build_sample_biblio( { author => 'Test Author', title => 'Test Title' } ); >+ >+ # Force some nullable columns to undef/empty >+ $biblio->set( { abstract => undef, notes => '', seriestitle => undef } )->store; >+ $biblio->discard_changes; >+ >+ my $data = $biblio->_unblessed_for_log; >+ >+ ok( ref $data eq 'HASH', '_unblessed_for_log returns a hashref' ); >+ ok( exists $data->{biblionumber}, 'biblionumber is present' ); >+ ok( exists $data->{title}, 'title (set value) is present' ); >+ ok( exists $data->{author}, 'author (set value) is present' ); >+ ok( !exists $data->{timestamp}, 'timestamp is excluded' ); >+ ok( !exists $data->{abstract}, 'undef field (abstract) is excluded' ); >+ ok( !exists $data->{notes}, 'empty-string field (notes) is excluded' ); >+ ok( !exists $data->{seriestitle}, 'undef field (seriestitle) is excluded' ); >+ >+ t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); >+ >+ # ADD log: diff should not contain timestamp >+ my $record = MARC::Record->new(); >+ $record->append_fields( MARC::Field->new( '245', '1', '0', 'a' => 'Log Test Title' ) ); >+ my ($new_biblionumber) = AddBiblio( $record, '' ); >+ >+ my $add_log = >+ Koha::ActionLogs->search( { object => $new_biblionumber, module => 'Cataloguing', action => 'ADD' } )->next; >+ ok( defined $add_log->diff, 'ADD log populates the diff column' ); >+ >+ my $add_diff = decode_json( $add_log->diff ); >+ my $diff_keys = exists $add_diff->{D} ? $add_diff->{D} : {}; >+ ok( !exists $diff_keys->{timestamp}, 'timestamp not present in ADD diff' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40135
:
194785
|
194941
|
195009
|
195010
|
195033
|
195034
|
195035
|
195183
|
195184
|
195195
|
195196
|
195197
|
195198
| 195199