my $homebranch = $builder->build_object( { class => 'Koha::Libraries' } );
my $holdingbranch = $builder->build_object( { class => 'Koha::Libraries' } );
- diag("Homebranch: " . $homebranch->branchcode . " : " . $homebranch->branchname);
# Add itemtypes
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } );
my $biblio = $builder->build_sample_biblio;
my $record = $biblio->metadata->record;
+ # Add an av
+ my $av = $builder->build_object( { class => 'Koha::AuthorisedValues' } );
+
# Suppress the record to test that suppression is never expanded
$record->field('942')->update( n => 1 );
# Add an AV ended field to test for AV expansion
$record->append_fields(
- MARC::Field->new( '590', '', '', a => 'CODE' ),
+ MARC::Field->new( '590', '', '', a => $av->authorised_value ),
);
- Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
- Koha::AuthorisedValue->new(
- {
- category => 'TEST',
- authorised_value => 'CODE',
- lib => 'Description should show',
- lib_opac => 'Description should show OPAC'
- }
- )->store;
my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
- $mss->update({ authorised_value => "TEST" });
+ $mss->update( { authorised_value => $av->category } );
my $cache = Koha::Caches->get_instance;
$cache->clear_from_cache("MarcCodedFields-");
$cache->clear_from_cache("libraries:name");
$cache->clear_from_cache("itemtype:description:en");
$cache->clear_from_cache("cn_sources:description");
- $cache->clear_from_cache("AV_descriptions:LOST");
+ $cache->clear_from_cache("AV_descriptions:" . $av->category);
C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
$biblio = Koha::Biblios->find( $biblio->biblionumber);
);
- is( $record->field('590')->subfield('a'), 'CODE', 'Record prior to filtering contains AV Code' );
+ is( $record->field('590')->subfield('a'), $av->authorised_value, 'Record prior to filtering contains AV Code' );
is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' );
is( $record->field('952')->subfield('a'), $homebranch->branchcode, 'Record prior to filtering contains homebranch branchcode' );
is( $record->field('952')->subfield('b'), $holdingbranch->branchcode, 'Record prior to filtering contains holdingbranch branchcode' );
my $result = $processor->process( $record );
is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' );
- is( $result->field('590')->subfield('a'), 'Description should show OPAC', 'Returned record contains AV OPAC description (interface defaults to opac)' );
- is( $record->field('590')->subfield('a'), 'Description should show OPAC', 'Original record now contains AV OPAC description (interface defaults to opac)' );
+ is( $result->field('590')->subfield('a'), $av->lib_opac, 'Returned record contains AV OPAC description (interface defaults to opac)' );
+ is( $record->field('590')->subfield('a'), $av->lib_opac, 'Original record now contains AV OPAC description (interface defaults to opac)' );
is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' );
is( $record->field('952')->subfield('a'), $homebranch->branchname, 'Record now contains homebranch branchname' );
is( $record->field('952')->subfield('b'), $holdingbranch->branchname, 'Record now contains holdingbranch branchname' );
# reset record for next test
$record = $biblio->metadata->record;
- is( $record->field('590')->subfield('a'), 'CODE', 'Record reset contains AV Code' );
+ is( $record->field('590')->subfield('a'), $av->authorised_value, 'Record reset contains AV Code' );
# set interface
$processor->options({ interface => 'intranet' });
$result = $processor->process( $record );
- is( $record->field('590')->subfield('a'), 'Description should show', 'Original record now contains AV description (interface set to intranet)' );
+ is( $record->field('590')->subfield('a'), $av->lib, 'Original record now contains AV description (interface set to intranet)' );
is( $record->field('942')->subfield('n'), 1, 'Item suppression field remains numeric after filtering' );
$schema->storage->txn_rollback();