Bugzilla – Attachment 51230 Details for
Bug 16428
The framework is not checked to know if a field is mapped
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16428: (regression tests)
Bug-16428-regression-tests.patch (text/plain), 3.89 KB, created by
Tomás Cohen Arazi (tcohen)
on 2016-05-05 13:16:36 UTC
(
hide
)
Description:
Bug 16428: (regression tests)
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2016-05-05 13:16:36 UTC
Size:
3.89 KB
patch
obsolete
>From ab3aaaaabb422b47af004fdc472d4b7279113a04 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 5 May 2016 09:51:09 -0300 >Subject: [PATCH] Bug 16428: (regression tests) > >This patch adds tests to t/db_dependent/Items.t to verify the kohafield >mapping is not always taken from the default framework, but from the correct >one. > >To test: >- Apply the patch >- Run: > $ prove t/db_dependent/Items.t >=> FAIL: Mapping is not done on the right framework > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Items.t | 80 +++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 79 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index 2b990c1..2beff35 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -26,7 +26,7 @@ use Koha::Library; > use t::lib::Mocks; > use t::lib::TestBuilder; > >-use Test::More tests => 9; >+use Test::More tests => 10; > > use Test::Warn; > >@@ -424,6 +424,82 @@ subtest 'SearchItems test' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'ModItemFromMarc tests' => sub { >+ >+ plan tests => 3; >+ >+ my $dbh = C4::Context->dbh; >+ my $builder = t::lib::TestBuilder->new; >+ >+ $schema->storage->txn_begin; >+ >+ my $branchcode = $builder->build({ >+ source => 'Branch', >+ })->{ branchcode }; >+ >+ my $frameworkcode = $builder->build({ >+ source => 'BiblioFramework' >+ })->{ frameworkcode }; >+ >+ my $msfstructure = $builder->build({ >+ source => 'MarcSubfieldStructure', >+ value => { >+ frameworkcode => $frameworkcode, >+ tagfield => 952, >+ tagsubfield => 'k', >+ kohafield => 'materials' >+ } >+ }); >+ >+ my $materials_value = 'materials_value'; >+ my ($itemfield) = GetMarcFromKohaField('items.itemnumber', ''); >+ my ($biblionumber) = get_biblio(); >+ # Make sure the default framework has 952$3 => items.materials >+ $dbh->do(q{ DELETE FROM marc_subfield_structure >+ WHERE kohafield="items.materials" AND >+ frameworkcode=""}, undef, $itemfield); >+ $dbh->do(q{ UPDATE marc_subfield_structure >+ SET kohafield="items.materials" >+ WHERE tagfield=? AND >+ tagsubfield="3" AND >+ frameworkcode=""}, undef, $itemfield); >+ >+ # Make sure cache is clean (TODO: change after bug 13074) >+ $C4::Items::default_values_for_mod_from_marc; >+ >+ # Add an item with a fixed materials value >+ my $item_record = MARC::Record->new; >+ $item_record->append_fields( >+ MARC::Field->new( >+ $itemfield, '', '', >+ '3' => $materials_value >+ ) >+ ); >+ my ( undef, undef, $itemnumber ) = AddItemFromMarc( $item_record, $biblionumber ); >+ my $item = Koha::Items->find( $itemnumber ); >+ is( $item->materials, $materials_value, 'Materials is correctly mapped on the default framework' ); >+ >+ # Change the biblio's framework >+ ModBiblioframework( $biblionumber, $frameworkcode ); >+ ModItemFromMarc( $item_record, $biblionumber, $itemnumber ); >+ $item = Koha::Items->find( $itemnumber ); >+ is( $item->materials, undef, 'Subfield 3 is not mapped on the new framework' ); >+ >+ # Now have the right subfield >+ $item_record = MARC::Record->new; >+ $item_record->append_fields( >+ MARC::Field->new( >+ $itemfield, '', '', >+ 'k' => $materials_value >+ ) >+ ); >+ ModItemFromMarc( $item_record, $biblionumber, $itemnumber ); >+ $item = Koha::Items->find( $itemnumber ); >+ is( $item->materials, $materials_value, 'Subfield mapping is taken from the biblio\'s framework' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'Koha::Item(s) tests' => sub { > > plan tests => 5; >@@ -563,3 +639,5 @@ sub get_biblio { > my ($bibnum, $bibitemnum) = AddBiblio($bib, ''); > return ($bibnum, $bibitemnum); > } >+ >+1; >-- >2.7.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 16428
:
51125
|
51230
|
51327
|
51430
|
51431