From 24ef3c0197c591e6a966f2e05c608b0d2ae293aa Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 11 May 2017 13:04:18 -0300 Subject: [PATCH] Bug 18579: Regression tests Content-Type: text/plain; charset=utf-8 This patch makes sure the tests have the biblio.biblionumber mapping mocked so we test the case where the mapping is to a control field instead of just regular data fields (in the case of UNIMARC). To test: - Apply the patch - Run: $ prove t/db_dependent/Koha/Filter/EmbedItemsAvailability.t => FAIL: Tests fail due to an attemp to access a subfield on a control field. Sponsored-by: ByWater Solutions Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy --- t/db_dependent/Koha/Filter/EmbedItemsAvailability.t | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t b/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t index 7110bf9..74a8d03e 100755 --- a/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t +++ b/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t @@ -18,6 +18,8 @@ use Modern::Perl; use Test::More tests => 1; +use Test::MockModule; + use t::lib::Mocks; use t::lib::TestBuilder; @@ -36,8 +38,26 @@ subtest 'EmbedItemsAvailability tests' => sub { $schema->storage->txn_begin(); + my $biblio = Test::MockModule->new('C4::Biblio'); + $biblio->mock( 'GetMarcFromKohaField', sub { + my ( $kohafield, $frameworkcode ) = @_; + if ( $kohafield eq 'biblio.biblionumber' ) { + if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { + return ( '001', '@' ); + } + else { + return ( '999', 'c' ); + } + } + else { + my $func_ref = $biblio->original( 'GetMarcFromKohaField' ); + &$func_ref( $kohafield, $frameworkcode ); + } + }); + # MARC21 tests t::lib::Mocks::mock_preference( 'marcflavour', 'MARC21' ); + # Create a dummy record my ( $biblionumber, $biblioitemnumber ) = AddBiblio(MARC::Record->new(), ''); -- 2.1.4