Bugzilla – Attachment 64113 Details for
Bug 18761
AutomaticItemModificationByAge.t tests are failing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18761: Fix tests for AutomaticItemModificationByAge.t - clear cache
Bug-18761-Fix-tests-for-AutomaticItemModificationB.patch (text/plain), 3.77 KB, created by
Jonathan Druart
on 2017-06-08 17:20:12 UTC
(
hide
)
Description:
Bug 18761: Fix tests for AutomaticItemModificationByAge.t - clear cache
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-06-08 17:20:12 UTC
Size:
3.77 KB
patch
obsolete
>From 0393ec8568d7dda3a7c82a9baecd803b10a5d9c2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Jun 2017 14:17:53 -0300 >Subject: [PATCH] Bug 18761: Fix tests for AutomaticItemModificationByAge.t - > clear cache > >The mapping structure is cached and may be wrong if already populated. >We need to clear the cache when a framework is modified >--- > .../Items/AutomaticItemModificationByAge.t | 32 ++++++++++++++++------ > 1 file changed, 24 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Items/AutomaticItemModificationByAge.t b/t/db_dependent/Items/AutomaticItemModificationByAge.t >index 05a92add1e..5240a719ba 100644 >--- a/t/db_dependent/Items/AutomaticItemModificationByAge.t >+++ b/t/db_dependent/Items/AutomaticItemModificationByAge.t >@@ -13,9 +13,9 @@ use C4::Items; > use Koha::DateUtils; > use t::lib::TestBuilder; > >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; > my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; > > my $builder = t::lib::TestBuilder->new; > >@@ -23,16 +23,25 @@ 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 > $dbh->do(q| > DELETE FROM marc_subfield_structure >- WHERE kohafield = 'items.new_status' OR kohafield = 'items.stocknumber' >-|); >+ WHERE ( kohafield = 'items.new_status' OR kohafield = 'items.stocknumber' ) >+ AND frameworkcode = ? >+|, undef, $frameworkcode); > > my $new_tagfield = 'i'; > $dbh->do(qq| > INSERT INTO marc_subfield_structure(tagfield, tagsubfield, kohafield, frameworkcode) >- VALUES ( 952, '$new_tagfield', 'items.new_status', '' ) >-|); >+ VALUES ( 952, ?, 'items.new_status', ? ) >+|, undef, $new_tagfield, $frameworkcode); >+ >+# Clear cache >+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("MarcSubfieldStructure-$frameworkcode"); > > my $record = MARC::Record->new(); > $record->append_fields( >@@ -40,7 +49,7 @@ $record->append_fields( > MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'), > MARC::Field->new('942', ' ', ' ', c => 'ITEMTYPE_T'), > ); >-my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, ''); >+my ($biblionumber, undef) = C4::Biblio::AddBiblio($record, $frameworkcode); > > my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem( > { >@@ -55,7 +64,7 @@ my ($item_bibnum, $item_bibitemnum, $itemnumber) = C4::Items::AddItem( > my $item = C4::Items::GetItem( $itemnumber ); > is ( $item->{new_status}, 'new_value', q|AddItem insert the 'new_status' field| ); > >-my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', ''); >+my ( $tagfield, undef ) = GetMarcFromKohaField('items.itemnumber', $frameworkcode); > my $marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); > is( $marc_item->subfield($tagfield, $new_tagfield), 'new_value', q|Koha mapping is correct|); > >@@ -288,3 +297,10 @@ C4::Items::ToggleNewStatus( { rules => \@rules } ); > > $modified_item = C4::Items::GetItem( $itemnumber ); > is( $modified_item->{new_status}, 'another_new_updated_value', q|ToggleNewStatus: conditions on biblioitems|); >+ >+# Clear cache >+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("MarcSubfieldStructure-$frameworkcode"); >-- >2.11.0
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 18761
:
64113
|
64176