From 4a4033393bcc8cb5c41dc1070ac3a4c64e42e181 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 13 Mar 2023 14:29:18 -0300 Subject: [PATCH] Bug 33214: Make tests use random data and clear the cache This trivial patch removes some wrongly hardcoded bits, and makes the tests also clear the cache before and after being run. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- t/db_dependent/Koha/Biblio.t | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 188625e113..af3a424bc9 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -718,6 +718,8 @@ subtest 'get_marc_notes() MARC21 tests' => sub { t::lib::Mocks::mock_preference( 'NotesToHide', '520' ); + my $av = $builder->build_object( { class => 'Koha::AuthorisedValues' } ); + my $biblio = $builder->build_sample_biblio; my $record = $biblio->metadata->record; $record->append_fields( @@ -726,21 +728,12 @@ subtest 'get_marc_notes() MARC21 tests' => sub { MARC::Field->new( '520', '', '', a => 'Note3 skipped' ), MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ), MARC::Field->new( '544', '', '', a => 'Note5' ), - MARC::Field->new( '590', '', '', a => 'CODE' ), + MARC::Field->new( '590', '', '', a => $av->authorised_value ), MARC::Field->new( '545', '', '', a => 'Invisible on OPAC' ), ); - Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store; - Koha::AuthorisedValue->new( - { - category => 'TEST', - authorised_value => 'CODE', - lib => 'Description should show', - lib_opac => 'Description should show OPAC' - } - )->store; my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); - $mss->update({ authorised_value => "TEST" }); + $mss->update({ authorised_value => $av->category }); $mss = Koha::MarcSubfieldStructures->find({tagfield => "545", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); $mss->update({ hidden => 1 }); @@ -749,6 +742,7 @@ subtest 'get_marc_notes() MARC21 tests' => sub { $cache->clear_from_cache("MarcStructure-0-"); $cache->clear_from_cache("MarcStructure-1-"); $cache->clear_from_cache("MarcSubfieldStructure-"); + $cache->clear_from_cache("MarcCodedFields-"); C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); $biblio = Koha::Biblios->find( $biblio->biblionumber); @@ -759,7 +753,7 @@ subtest 'get_marc_notes() MARC21 tests' => sub { is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Note shows if not opac (Hidden by Indicator)" ); is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' ); - is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' ); + is( $notes->[5]->{marcnote}, $av->lib, 'Authorised value is correctly parsed to show description rather than code' ); is( $notes->[6]->{marcnote}, 'Invisible on OPAC', 'Note shows if not opac (Hidden by framework)' ); is( @$notes, 7, 'No more notes' ); $notes = $biblio->get_marc_notes({ opac => 1 }); @@ -767,12 +761,13 @@ subtest 'get_marc_notes() MARC21 tests' => sub { is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' ); - is( $notes->[4]->{marcnote}, 'Description should show OPAC', 'Authorised value is correctly parsed for OPAC to show description rather than code' ); + is( $notes->[4]->{marcnote}, $av->lib_opac, 'Authorised value is correctly parsed for OPAC to show description rather than code' ); is( @$notes, 5, 'No more notes' ); $cache->clear_from_cache("MarcStructure-0-"); $cache->clear_from_cache("MarcStructure-1-"); $cache->clear_from_cache("MarcSubfieldStructure-"); + $cache->clear_from_cache("MarcCodedFields-"); $schema->storage->txn_rollback; }; -- 2.30.2