From 41ef209a831e9c8dd7cd64ba3760ba9fcdeb05a5 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Tue, 3 Mar 2026 20:00:57 +0000 Subject: [PATCH] Bug 41982: Unit tests Caveat, errors from QA script about 'http://' are misleading. --- t/db_dependent/XSLT.t | 50 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t index 1ce78b12ae..a7e59e8653 100755 --- a/t/db_dependent/XSLT.t +++ b/t/db_dependent/XSLT.t @@ -21,7 +21,7 @@ use File::Temp; use File::Path qw/make_path/; use MARC::Record; use Test::NoWarnings; -use Test::More tests => 5; +use Test::More tests => 6; use Test::Warn; use t::lib::TestBuilder; use t::lib::Mocks; @@ -308,3 +308,51 @@ subtest 'buildKohaItemsNamespace() including/omitting items tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'buildKohaItemsNamespace() EasyAnalyticalRecords items' => sub { + plan tests => 3; + + $schema->storage->txn_begin; + + t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); + + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $library_name = $library->branchname; + + my $biblio1 = $builder->build_sample_biblio; + my $biblio2 = $builder->build_sample_biblio; + + my $item_1 = $builder->build_sample_item( { biblionumber => $biblio1->biblionumber, library => $library->id } ); + + my $marc2 = $biblio2->metadata->record; + $marc2->insert_fields_ordered( + MARC::Field->new( + '773', '0', ' ', + 0 => $biblio1->biblionumber, + 9 => $item_1->itemnumber + ) + ); + C4::Biblio::ModBiblio( $marc2, $biblio2->biblionumber, '' ); + + t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', '0' ); + my $xml = C4::XSLT::buildKohaItemsNamespace( $biblio2->biblionumber, undef, undef ); + is( + $xml, '', + 'Empty XML' + ); + + t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', '1' ); + $xml = C4::XSLT::buildKohaItemsNamespace( $biblio2->biblionumber, undef, undef ); + isnt( + $xml, + '', + 'Items present' + ); + like( + $xml, + qr{$library_name}, + '$item_1 present in the XML' + ); + + $schema->storage->txn_rollback; +}; -- 2.39.5