From 171c040796a9c5f96b47d0211c7bbb4d1d49b202 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 16 Oct 2025 08:47:24 +0200 Subject: [PATCH] Bug 41031: Fix the subtest check_fixed_length in MARC21.t Content-Type: text/plain; charset=utf-8 Add test on empty marc object. Remove MARC21 module and create with parent MARC object. Test plan: Run t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t Signed-off-by: Marcel de Rooy --- .../Biblio/Metadata/Extractor/MARC/MARC21.t | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t b/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t index 6797cb5ed5..a1840021a6 100755 --- a/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t +++ b/t/db_dependent/Koha/Biblio/Metadata/Extractor/MARC/MARC21.t @@ -28,7 +28,6 @@ use t::lib::Mocks; use C4::Biblio qw(ModBiblio); use Koha::Biblio::Metadata::Extractor; -use Koha::Biblio::Metadata::Extractor::MARC::MARC21; my $schema = Koha::Database->schema; my $builder = t::lib::TestBuilder->new; @@ -92,19 +91,24 @@ subtest 'get_normalized_oclc() tests' => sub { subtest 'check_fixed_length' => sub { - plan tests => 6; + plan tests => 8; $schema->storage->txn_begin; - my $record = MARC::Record->new; + # Check empty object + my $record = MARC::Record->new; + my $extractor = Koha::Biblio::Metadata::Extractor::MARC->new( { metadata => $record } ); + my $result = $extractor->check_fixed_length; + is( scalar @{ $result->{passed} }, 0, 'No passed fields' ); + is( scalar @{ $result->{failed} }, 0, 'No failed fields' ); + $record->append_fields( MARC::Field->new( '005', '0123456789012345' ), ); my $biblio = $builder->build_sample_biblio; ModBiblio( $record, $biblio->biblionumber ); - my $extractor; - $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { biblio => $biblio } ); - my $result = $extractor->check_fixed_length; + $extractor = Koha::Biblio::Metadata::Extractor::MARC->new( { biblio => $biblio } ); + $result = $extractor->check_fixed_length; is( $result->{passed}->[0], '005', 'Check first passed field' ); is( scalar @{ $result->{failed} }, 0, 'Check failed count' ); @@ -116,7 +120,7 @@ subtest 'check_fixed_length' => sub { ); # Passing latest record changes via metadata now - $extractor = Koha::Biblio::Metadata::Extractor::MARC::MARC21->new( { metadata => $record } ); + $extractor = Koha::Biblio::Metadata::Extractor::MARC->new( { metadata => $record } ); $result = $extractor->check_fixed_length; is( $result->{passed}->[1], '007', 'Check second passed field' ); is( $result->{passed}->[2], '007', 'Check third passed field' ); -- 2.39.5