Bugzilla – Attachment 60255 Details for
Bug 18045
Reserves.t can fail because of caching issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18045: Fix Reserves.t tests - caching issues
Bug-18045-Fix-Reservest-tests---caching-issues.patch (text/plain), 3.78 KB, created by
Nick Clemens (kidclamp)
on 2017-02-15 13:29:36 UTC
(
hide
)
Description:
Bug 18045: Fix Reserves.t tests - caching issues
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-02-15 13:29:36 UTC
Size:
3.78 KB
patch
obsolete
>From f754c3b547b8ba489dbdbd8f98dc1ec577507d3c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 2 Feb 2017 01:09:38 +0100 >Subject: [PATCH] Bug 18045: Fix Reserves.t tests - caching issues > >If the cache has to be cleaned when marc structure is updated. > >Before this patch, if the age restriction was not mapped, Reserves.t >failed with: > Tag "" is not a valid tag. at t/db_dependent/Reserves.t line 523. > >Test plan: >Just confirm that the tests still pass and that the changes make sense. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >It seems that only removing the key MarcSubfieldStructure- should be >enough, but it does not hurt either to remove those four keys. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Reserves.t | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index a70a28a..536354d 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -32,6 +32,7 @@ use C4::Circulation; > use C4::Items; > use C4::Members; > use C4::Reserves; >+use Koha::Caches; > use Koha::DateUtils; > use Koha::Holds; > use Koha::Libraries; >@@ -49,8 +50,15 @@ my $dbh = C4::Context->dbh; > > my $builder = t::lib::TestBuilder->new; > >+my $frameworkcode = q||; >+ > # Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached >-$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a'"); >+$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode); >+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"); > > ## Setup Test > # Add branches >@@ -84,7 +92,7 @@ else { > ); > } > my ($bibnum, $bibitemnum); >-($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); >+($bibnum, $title, $bibitemnum) = AddBiblio($bib, $frameworkcode); > > # Create a helper item instance for testing > my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( >@@ -225,7 +233,7 @@ $bib2->append_fields( > ); > > # create one item belonging to FPL and one belonging to CPL >-my ($bibnum2, $bibitemnum2) = AddBiblio($bib, ''); >+my ($bibnum2, $bibitemnum2) = AddBiblio($bib, $frameworkcode); > my ($itemnum_cpl, $itemnum_fpl); > ( undef, undef, $itemnum_cpl ) = AddItem( > { homebranch => $branch_1, >@@ -521,7 +529,7 @@ t::lib::Mocks::mock_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' ); > my $record = GetMarcBiblio( $bibnum ); > my ( $ageres_tagid, $ageres_subfieldid ) = GetMarcFromKohaField( "biblioitems.agerestriction" ); > $record->append_fields( MARC::Field->new($ageres_tagid, '', '', $ageres_subfieldid => 'PEGI 16') ); >-C4::Biblio::ModBiblio( $record, $bibnum, '' ); >+C4::Biblio::ModBiblio( $record, $bibnum, $frameworkcode ); > > is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 'OK', "Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds" ); > >@@ -698,6 +706,11 @@ MoveReserve( $itemnumber, $borrowernumber ); > is( $status, 'Reserved', 'MoveReserve did not fill future hold of 3 days'); > $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("MarcSubfieldStructure-$frameworkcode"); >+ > # we reached the finish > $schema->storage->txn_rollback(); > >-- >2.1.4
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 18045
:
59858
|
59868
| 60255