Bug 18579: Regression tests

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 <katrin.fischer.83@web.de>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2017-05-11 13:04:18 -03:00 committed by Kyle M Hall
parent 7a4f3c17a8
commit 3e1d76dbc0

View file

@ -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(), '');