From 5a63523f593736e282d4b8dc590f250f0339c2eb Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 10 Aug 2017 10:59:07 +0200 Subject: [PATCH] Bug 19096: Adjusts unit tests The subroutines listed in the former patch are extensively tested in Biblio.t, TransformKohaToMarc.t and TransformMarcToKoha.t. These tests do no longer use new frameworks to add mappings. In Biblio.t and TransformMarcToKoha.t we also test passing an individual framework code (for an empty framework) to see if Default is still used. Note that this parameter will be removed later on. In Items.t the cache keys MarcStructure-0- and MarcStructure-1- are not touched, so they do not need to be cleared. The cache key default_value_for_mod_marc- should be used without framework now. Similar adjustments in Items/AutomaticItemModificationByAge.t and Reserves.t. Furthermore the subtest for _build_default_values_for_mod_marc in Items.t is adjusted since framework is no longer relevant. The biblio record with items is created in a new framework, but the mappings from Default are consulted. Test plan: Run all adjusted unit tests. Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- t/db_dependent/Biblio.t | 35 +++++--- t/db_dependent/Biblio/TransformKohaToMarc.t | 56 +++++------- t/db_dependent/Biblio/TransformMarcToKoha.t | 41 +++++---- t/db_dependent/Items.t | 85 +++++-------------- .../Items/AutomaticItemModificationByAge.t | 6 +- t/db_dependent/Reserves.t | 4 +- 6 files changed, 95 insertions(+), 132 deletions(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index 1782fff05a..4c4e72da8f 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -19,10 +19,11 @@ use Modern::Perl; use Test::More tests => 9; use Test::MockModule; - use List::MoreUtils qw( uniq ); use MARC::Record; + use t::lib::Mocks qw( mock_preference ); +use t::lib::TestBuilder; use Koha::Database; use Koha::Caches; @@ -47,7 +48,7 @@ subtest 'GetMarcSubfieldStructureFromKohaField' => sub { ); # biblio.biblionumber must be mapped so this should return something - my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber', ''); + my $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber'); ok(defined $marc_subfield_structure, "There is a result"); is(ref $marc_subfield_structure, "HASH", "Result is a hashref"); @@ -58,13 +59,13 @@ subtest 'GetMarcSubfieldStructureFromKohaField' => sub { like($marc_subfield_structure->{tagfield}, qr/^\d{3}$/, "tagfield is a valid tagfield"); # Add a test for list context (BZ 10306) - my @results = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber', ''); + my @results = GetMarcSubfieldStructureFromKohaField('biblio.biblionumber'); is( @results, 1, 'We expect only one mapping' ); is_deeply( $results[0], $marc_subfield_structure, 'The first entry should be the same hashref as we had before' ); # foo.bar does not exist so this should return undef - $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar', ''); + $marc_subfield_structure = GetMarcSubfieldStructureFromKohaField('foo.bar'); is($marc_subfield_structure, undef, "invalid kohafield returns undef"); }; @@ -73,12 +74,9 @@ subtest "GetMarcSubfieldStructure" => sub { plan tests => 5; # Add multiple Koha to Marc mappings - my $mapping1 = Koha::MarcSubfieldStructures->find('','399','a') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '399', tagsubfield => 'a' }); - $mapping1->kohafield( "mytable.nicepages" ); - $mapping1->store; - my $mapping2 = Koha::MarcSubfieldStructures->find('','399','b') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '399', tagsubfield => 'b' }); - $mapping2->kohafield( "mytable.nicepages" ); - $mapping2->store; + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '399', tagsubfield => [ 'a', 'b' ] })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '399', tagsubfield => 'a', kohafield => "mytable.nicepages" })->store; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '399', tagsubfield => 'b', kohafield => "mytable.nicepages" })->store; Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); my $structure = C4::Biblio::GetMarcSubfieldStructure(''); @@ -95,13 +93,13 @@ subtest "GetMarcSubfieldStructure" => sub { }; subtest "GetMarcFromKohaField" => sub { - plan tests => 6; + plan tests => 8; #NOTE: We are building on data from the previous subtest # With: field 399 / mytable.nicepages # Check call in list context for multiple mappings - my @retval = C4::Biblio::GetMarcFromKohaField('mytable.nicepages', ''); + my @retval = C4::Biblio::GetMarcFromKohaField('mytable.nicepages'); is( @retval, 4, 'Should return two tags and subfields' ); is( $retval[0], '399', 'Check first tag' ); is( $retval[1], 'a', 'Check first subfield' ); @@ -109,8 +107,19 @@ subtest "GetMarcFromKohaField" => sub { is( $retval[3], 'b', 'Check second subfield' ); # Check same call in scalar context - is( C4::Biblio::GetMarcFromKohaField('mytable.nicepages', ''), '399', + is( C4::Biblio::GetMarcFromKohaField('mytable.nicepages'), '399', 'GetMarcFromKohaField returns first tag in scalar context' ); + + # Bug 19096 Default is authoritative + # If we add a new empty framework, we should still get the mappings + # from Default. CAUTION: This test passes intentionally the obsoleted + # framework parameter. + my $new_fw = t::lib::TestBuilder->new->build({source => 'BiblioFramework'}); + @retval = C4::Biblio::GetMarcFromKohaField( + 'mytable.nicepages', $new_fw->{frameworkcode}, + ); + is( @retval, 4, 'Still got two pairs of tags/subfields' ); + is( $retval[0].$retval[1], '399a', 'Including 399a' ); }; # Mocking variables diff --git a/t/db_dependent/Biblio/TransformKohaToMarc.t b/t/db_dependent/Biblio/TransformKohaToMarc.t index 2222d6f6fc..90b4d847dd 100644 --- a/t/db_dependent/Biblio/TransformKohaToMarc.t +++ b/t/db_dependent/Biblio/TransformKohaToMarc.t @@ -14,12 +14,10 @@ my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; # Create/overwrite some Koha to MARC mappings in default framework -my $mapping1 = Koha::MarcSubfieldStructures->find('','300','a') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' }); -$mapping1->kohafield( "mytable.nicepages" ); -$mapping1->store; -my $mapping2 = Koha::MarcSubfieldStructures->find('','300','b') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' }); -$mapping2->kohafield( "mytable2.goodillustrations" ); -$mapping2->store; +Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete; +Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a', kohafield => "mytable.nicepages" })->store; +Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' })->delete; +Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => "mytable2.goodillustrations" })->store; Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); my $record = C4::Biblio::TransformKohaToMarc({ @@ -44,10 +42,9 @@ is_deeply( \@subfields, [ subtest "Multiple Koha to MARC mappings (BZ 10306)" => sub { plan tests => 4; - # 300a and 260d mapped to mytable.nicepages - my $mapping3 = Koha::MarcSubfieldStructures->find('','260','d') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'd' }); - $mapping3->kohafield( "mytable.nicepages" ); - $mapping3->store; + # Add260d mapping so that 300a and 260d both map to mytable.nicepages + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '260', tagsubfield => 'd' })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'd', kohafield => "mytable.nicepages" })->store; Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); # Include two values in goodillustrations too: should result in two @@ -63,52 +60,39 @@ subtest "Multiple Koha to MARC mappings (BZ 10306)" => sub { "Check second 300b" ); }; -subtest "Working with control fields in another framework" => sub { - plan tests => 2; - - # Add a new framework - my $fw = t::lib::TestBuilder->new->build_object({ - class => 'Koha::BiblioFrameworks' - }); +subtest "Working with control fields" => sub { + plan tests => 1; # Map a controlfield to 'fullcontrol' - my $mapping = Koha::MarcSubfieldStructure->new({ frameworkcode => $fw->frameworkcode, tagfield => '001', tagsubfield => '@', kohafield => 'fullcontrol' }); - $mapping->store; + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '001', tagsubfield => '@' })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '001', tagsubfield => '@', kohafield => "fullcontrol" })->store; + Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); - # First test in the wrong framework my @cols = ( notexist => 'i am not here', fullcontrol => 'all' ); my $record = C4::Biblio::TransformKohaToMarc( { @cols } ); - is( $record->field('001'), undef, - 'With default framework we should not find a 001 controlfield' ); - # Now include the framework parameter and test 001 - $record = C4::Biblio::TransformKohaToMarc( { @cols }, $fw->frameworkcode ); - is( $record->field('001')->data, "all", "Check controlfield 001 with right frameworkcode" ); - - # Remove from cache - Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-".$fw->frameworkcode ); + is( $record->field('001')->data, 'all', 'Verify field 001' ); }; subtest "Add test for no_split option" => sub { plan tests => 4; - my $fwc = t::lib::TestBuilder->new->build({ source => 'BiblioFramework' })->{frameworkcode}; - Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '952', tagsubfield => 'a', kohafield => 'items.fld1' })->store; - Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '952', tagsubfield => 'b', kohafield => 'items.fld1' })->store; - Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-$fwc" ); + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'a' })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'a', kohafield => 'items.fld1' })->store; + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'b' })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'b', kohafield => 'items.fld1' })->store; + Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); # Test single value in fld1 my @cols = ( 'items.fld1' => '01' ); - my $record = C4::Biblio::TransformKohaToMarc( { @cols }, $fwc, { no_split => 1 } ); + my $record = C4::Biblio::TransformKohaToMarc( { @cols }, { no_split => 1 } ); is( $record->subfield( '952', 'a' ), '01', 'Check single in 952a' ); is( $record->subfield( '952', 'b' ), '01', 'Check single in 952b' ); # Test glued (composite) value in fld1 @cols = ( 'items.fld1' => '01 | 02' ); - $record = C4::Biblio::TransformKohaToMarc( { @cols }, $fwc, { no_split => 1 } ); + $record = C4::Biblio::TransformKohaToMarc( { @cols }, { no_split => 1 } ); is( $record->subfield( '952', 'a' ), '01 | 02', 'Check composite in 952a' ); is( $record->subfield( '952', 'b' ), '01 | 02', 'Check composite in 952b' ); - - Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-$fwc" ); }; # Cleanup diff --git a/t/db_dependent/Biblio/TransformMarcToKoha.t b/t/db_dependent/Biblio/TransformMarcToKoha.t index 806b7591b3..f47632d728 100644 --- a/t/db_dependent/Biblio/TransformMarcToKoha.t +++ b/t/db_dependent/Biblio/TransformMarcToKoha.t @@ -33,15 +33,16 @@ use C4::Biblio; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -# Create a new framework with a few mappings +# Create a few mappings # Note: TransformMarcToKoha wants a table name (biblio, biblioitems or items) -our $fwc = t::lib::TestBuilder->new->build_object({ class => 'Koha::BiblioFrameworks' })->frameworkcode; -Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '300', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; -Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '300', tagsubfield => 'b', kohafield => 'biblio.field2' })->store; -Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '500', tagsubfield => 'a', kohafield => 'biblio.field3' })->store; +Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => [ '300', '500' ] })->delete; +Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; +Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => 'biblio.field2' })->store; +Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '500', tagsubfield => 'a', kohafield => 'biblio.field3' })->store; +Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); subtest 'Test a few mappings' => sub { - plan tests => 6; + plan tests => 7; my $marc = MARC::Record->new; $marc->append_fields( @@ -49,41 +50,49 @@ subtest 'Test a few mappings' => sub { MARC::Field->new( '300', '', '', a => 'a2', b => 'b2' ), MARC::Field->new( '500', '', '', a => 'note1', a => 'note2' ), ); - my $result = C4::Biblio::TransformMarcToKoha( $marc, $fwc ); + my $result = C4::Biblio::TransformMarcToKoha( $marc ); # Note: TransformMarcToKoha stripped the table prefix biblio. is( keys %{$result}, 3, 'Found all three mappings' ); is( $result->{field1}, 'a1 | a2', 'Check field1 results' ); is( $result->{field2}, 'b1 | b2', 'Check field2 results' ); is( $result->{field3}, 'note1 | note2', 'Check field3 results' ); - is( C4::Biblio::TransformMarcToKohaOneField( 'biblio.field1', $marc, $fwc ), + is( C4::Biblio::TransformMarcToKohaOneField( 'biblio.field1', $marc ), $result->{field1}, 'TransformMarcToKohaOneField returns biblio.field1'); - is( C4::Biblio::TransformMarcToKohaOneField( 'field4', $marc, $fwc ), + is( C4::Biblio::TransformMarcToKohaOneField( 'field4', $marc ), undef, 'TransformMarcToKohaOneField returns undef' ); + + # Bug 19096 Default is authoritative now + # Test passing another framework + # CAUTION: This parameter of TransformMarcToKoha will be removed later + my $new_fw = t::lib::TestBuilder->new->build({source => 'BiblioFramework'}); + $result = C4::Biblio::TransformMarcToKoha($marc, $new_fw->{frameworkcode}); + is( keys %{$result}, 3, 'Still found all three mappings' ); }; subtest 'Multiple mappings for one kohafield' => sub { plan tests => 4; # Add another mapping to field1 - Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '510', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; - Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-$fwc" ); + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'a', kohafield => 'biblio.field1' })->store; + Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); my $marc = MARC::Record->new; $marc->append_fields( MARC::Field->new( '300', '', '', a => '3a' ) ); - my $result = C4::Biblio::TransformMarcToKoha( $marc, $fwc ); + my $result = C4::Biblio::TransformMarcToKoha( $marc ); is_deeply( $result, { field1 => '3a' }, 'Simple start' ); $marc->append_fields( MARC::Field->new( '510', '', '', a => '' ) ); - $result = C4::Biblio::TransformMarcToKoha( $marc, $fwc ); + $result = C4::Biblio::TransformMarcToKoha( $marc ); is_deeply( $result, { field1 => '3a' }, 'An empty 510a makes no difference' ); $marc->append_fields( MARC::Field->new( '510', '', '', a => '51' ) ); - $result = C4::Biblio::TransformMarcToKoha( $marc, $fwc ); + $result = C4::Biblio::TransformMarcToKoha( $marc ); is_deeply( $result, { field1 => '3a | 51' }, 'Got 300a and 510a' ); - is( C4::Biblio::TransformMarcToKohaOneField( 'biblio.field1', $marc, $fwc ), + is( C4::Biblio::TransformMarcToKohaOneField( 'biblio.field1', $marc ), '3a | 51', 'TransformMarcToKohaOneField returns biblio.field1' ); }; # Cleanup -Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-$fwc" ); +Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index f9ab049fcf..8c85959bb7 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -17,6 +17,7 @@ # use Modern::Perl; +use Data::Dumper; use MARC::Record; use C4::Biblio; @@ -26,6 +27,9 @@ use Koha::Library; use t::lib::Mocks; use t::lib::TestBuilder; +use Koha::MarcSubfieldStructures; +use Koha::Caches; + use Test::More tests => 12; use Test::Warn; @@ -413,7 +417,7 @@ subtest 'SearchItems test' => sub { my $cache = Koha::Caches->get_instance(); $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); - $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); + $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); my $item3_record = new MARC::Record; @@ -444,7 +448,7 @@ subtest 'SearchItems test' => sub { # Clear cache $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); - $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); + $cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); ModItemFromMarc($item3_record, $biblionumber, $item3_itemnumber); @@ -614,57 +618,19 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { $schema->storage->txn_begin(); my $builder = t::lib::TestBuilder->new; - my $framework = $builder->build({ - source => 'BiblioFramework', - }); - # Link biblio.biblionumber and biblioitems.biblioitemnumber to avoid _koha_marc_update_bib_ids to fail with 'no biblio[item]number tag for framework" - $builder->build({ - source => 'MarcSubfieldStructure', - value => { - frameworkcode => $framework->{frameworkcode}, - kohafield => 'biblio.biblionumber', - tagfield => '999', - tagsubfield => 'c', - } - }); - $builder->build({ - source => 'MarcSubfieldStructure', - value => { - frameworkcode => $framework->{frameworkcode}, - kohafield => 'biblioitems.biblioitemnumber', - tagfield => '999', - tagsubfield => 'd', - } - }); - my $mss_itemnumber = $builder->build({ - source => 'MarcSubfieldStructure', - value => { - frameworkcode => $framework->{frameworkcode}, - kohafield => 'items.itemnumber', - tagfield => '952', - tagsubfield => '9', - } - }); + my $framework = $builder->build({ source => 'BiblioFramework' }); - my $mss_barcode = $builder->build({ - source => 'MarcSubfieldStructure', - value => { - frameworkcode => $framework->{frameworkcode}, - kohafield => 'items.barcode', - tagfield => '952', - tagsubfield => 'p', - } - }); + # Link biblio.biblionumber and biblioitems.biblioitemnumber to avoid _koha_marc_update_bib_ids to fail with 'no biblio[item]number tag for framework" + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '999', tagsubfield => [ 'c', 'd' ] })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '999', tagsubfield => 'c', kohafield => 'biblio.biblionumber' })->store; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '999', tagsubfield => 'd', kohafield => 'biblioitems.biblioitemnumber' })->store; - my $mss_itemtype = $builder->build({ - source => 'MarcSubfieldStructure', - value => { - frameworkcode => $framework->{frameworkcode}, - kohafield => 'items.itype', - tagfield => '952', - tagsubfield => 'y', - } - }); + # Same for item fields: itemnumber, barcode, itype + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => [ '9', 'p', 'y' ] })->delete; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => '9', kohafield => 'items.itemnumber' })->store; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'p', kohafield => 'items.barcode' })->store; + Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'y', kohafield => 'items.itype' })->store; + Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype}; @@ -701,20 +667,13 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { $item = GetItem($item_itemnumber); is( $item->{barcode}, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' ); - # Remove the mapping - my $dbh = C4::Context->dbh; - $dbh->do(q| - DELETE FROM marc_subfield_structure - WHERE kohafield = 'items.barcode' - AND frameworkcode = ? - |, undef, $framework->{frameworkcode} ); + # Remove the mapping for barcode + Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'p' })->delete; # And make sure the caches are cleared my $cache = Koha::Caches->get_instance(); - $cache->clear_from_cache("MarcStructure-0-" . $framework->{frameworkcode}); - $cache->clear_from_cache("MarcStructure-1-" . $framework->{frameworkcode}); - $cache->clear_from_cache("default_value_for_mod_marc-" . $framework->{frameworkcode}); - $cache->clear_from_cache("MarcSubfieldStructure-" . $framework->{frameworkcode}); + $cache->clear_from_cache("default_value_for_mod_marc-"); + $cache->clear_from_cache("MarcSubfieldStructure-"); # Update the MARC field with another value $item_record->delete_fields( $barcode_field ); @@ -729,6 +688,8 @@ subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { $item = GetItem($item_itemnumber); is ( $item->{barcode}, $a_barcode, 'items.barcode is not mapped anymore, so the DB column has not been updated' ); + $cache->clear_from_cache("default_value_for_mod_marc-"); + $cache->clear_from_cache( "MarcSubfieldStructure-" ); $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t index 3ce3f7812d..b93c62681c 100644 --- a/t/db_dependent/Items/AutomaticItemModificationByAge.t +++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t @@ -23,7 +23,7 @@ my $builder = t::lib::TestBuilder->new; my $library = $builder->build( { source => 'Branch' })->{branchcode}; my $library2 = $builder->build( { source => 'Branch' })->{branchcode}; -my $frameworkcode = ''; # FIXME We do not want to insert the whole mapping, but we should use another frameworkcode +my $frameworkcode = ''; # Use Default for Koha to MARC mappings $dbh->do(q| DELETE FROM marc_subfield_structure WHERE ( kohafield = 'items.new_status' OR kohafield = 'items.stocknumber' ) @@ -40,7 +40,7 @@ $dbh->do(qq| my $cache = Koha::Caches->get_instance(); $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); -$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); +$cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); my $record = MARC::Record->new(); @@ -302,5 +302,5 @@ is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus $cache = Koha::Caches->get_instance(); $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); -$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); +$cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index fd79427911..992e878c03 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -59,7 +59,7 @@ $dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestricti my $cache = Koha::Caches->get_instance; $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); -$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); +$cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); ## Setup Test @@ -616,7 +616,7 @@ $dbh->do('DELETE FROM reserves', undef, ($bibnum)); $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); -$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); +$cache->clear_from_cache("default_value_for_mod_marc-"); $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); subtest '_koha_notify_reserve() tests' => sub { -- 2.39.5