|
Lines 43-49
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 43 |
my $homebranch = $builder->build_object( { class => 'Koha::Libraries' } ); |
43 |
my $homebranch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 44 |
my $holdingbranch = $builder->build_object( { class => 'Koha::Libraries' } ); |
44 |
my $holdingbranch = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 45 |
|
45 |
|
| 46 |
diag("Homebranch: " . $homebranch->branchcode . " : " . $homebranch->branchname); |
|
|
| 47 |
# Add itemtypes |
46 |
# Add itemtypes |
| 48 |
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } ); |
47 |
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } ); |
| 49 |
|
48 |
|
|
Lines 51-75
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 51 |
my $biblio = $builder->build_sample_biblio; |
50 |
my $biblio = $builder->build_sample_biblio; |
| 52 |
my $record = $biblio->metadata->record; |
51 |
my $record = $biblio->metadata->record; |
| 53 |
|
52 |
|
|
|
53 |
# Add an av |
| 54 |
my $av = $builder->build_object( { class => 'Koha::AuthorisedValues' } ); |
| 55 |
|
| 54 |
# Suppress the record to test that suppression is never expanded |
56 |
# Suppress the record to test that suppression is never expanded |
| 55 |
$record->field('942')->update( n => 1 ); |
57 |
$record->field('942')->update( n => 1 ); |
| 56 |
|
58 |
|
| 57 |
# Add an AV ended field to test for AV expansion |
59 |
# Add an AV ended field to test for AV expansion |
| 58 |
$record->append_fields( |
60 |
$record->append_fields( |
| 59 |
MARC::Field->new( '590', '', '', a => 'CODE' ), |
61 |
MARC::Field->new( '590', '', '', a => $av->authorised_value ), |
| 60 |
); |
62 |
); |
| 61 |
|
63 |
|
| 62 |
Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store; |
|
|
| 63 |
Koha::AuthorisedValue->new( |
| 64 |
{ |
| 65 |
category => 'TEST', |
| 66 |
authorised_value => 'CODE', |
| 67 |
lib => 'Description should show', |
| 68 |
lib_opac => 'Description should show OPAC' |
| 69 |
} |
| 70 |
)->store; |
| 71 |
my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); |
64 |
my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode }); |
| 72 |
$mss->update({ authorised_value => "TEST" }); |
65 |
$mss->update( { authorised_value => $av->category } ); |
| 73 |
|
66 |
|
| 74 |
my $cache = Koha::Caches->get_instance; |
67 |
my $cache = Koha::Caches->get_instance; |
| 75 |
$cache->clear_from_cache("MarcCodedFields-"); |
68 |
$cache->clear_from_cache("MarcCodedFields-"); |
|
Lines 77-83
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 77 |
$cache->clear_from_cache("libraries:name"); |
70 |
$cache->clear_from_cache("libraries:name"); |
| 78 |
$cache->clear_from_cache("itemtype:description:en"); |
71 |
$cache->clear_from_cache("itemtype:description:en"); |
| 79 |
$cache->clear_from_cache("cn_sources:description"); |
72 |
$cache->clear_from_cache("cn_sources:description"); |
| 80 |
$cache->clear_from_cache("AV_descriptions:LOST"); |
73 |
$cache->clear_from_cache("AV_descriptions:" . $av->category); |
| 81 |
|
74 |
|
| 82 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
75 |
C4::Biblio::ModBiblio( $record, $biblio->biblionumber ); |
| 83 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
76 |
$biblio = Koha::Biblios->find( $biblio->biblionumber); |
|
Lines 94-100
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 94 |
); |
87 |
); |
| 95 |
|
88 |
|
| 96 |
|
89 |
|
| 97 |
is( $record->field('590')->subfield('a'), 'CODE', 'Record prior to filtering contains AV Code' ); |
90 |
is( $record->field('590')->subfield('a'), $av->authorised_value, 'Record prior to filtering contains AV Code' ); |
| 98 |
is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' ); |
91 |
is( $record->field('942')->subfield('n'), 1, 'Record suppression is numeric prior to filtering' ); |
| 99 |
is( $record->field('952')->subfield('a'), $homebranch->branchcode, 'Record prior to filtering contains homebranch branchcode' ); |
92 |
is( $record->field('952')->subfield('a'), $homebranch->branchcode, 'Record prior to filtering contains homebranch branchcode' ); |
| 100 |
is( $record->field('952')->subfield('b'), $holdingbranch->branchcode, 'Record prior to filtering contains holdingbranch branchcode' ); |
93 |
is( $record->field('952')->subfield('b'), $holdingbranch->branchcode, 'Record prior to filtering contains holdingbranch branchcode' ); |
|
Lines 110-117
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 110 |
|
103 |
|
| 111 |
my $result = $processor->process( $record ); |
104 |
my $result = $processor->process( $record ); |
| 112 |
is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' ); |
105 |
is( ref($result), 'MARC::Record', 'It returns a reference to a MARC::Record object' ); |
| 113 |
is( $result->field('590')->subfield('a'), 'Description should show OPAC', 'Returned record contains AV OPAC description (interface defaults to opac)' ); |
106 |
is( $result->field('590')->subfield('a'), $av->lib_opac, 'Returned record contains AV OPAC description (interface defaults to opac)' ); |
| 114 |
is( $record->field('590')->subfield('a'), 'Description should show OPAC', 'Original record now contains AV OPAC description (interface defaults to opac)' ); |
107 |
is( $record->field('590')->subfield('a'), $av->lib_opac, 'Original record now contains AV OPAC description (interface defaults to opac)' ); |
| 115 |
is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' ); |
108 |
is( $record->field('942')->subfield('n'), 1, 'Record suppression is still numeric after filtering' ); |
| 116 |
is( $record->field('952')->subfield('a'), $homebranch->branchname, 'Record now contains homebranch branchname' ); |
109 |
is( $record->field('952')->subfield('a'), $homebranch->branchname, 'Record now contains homebranch branchname' ); |
| 117 |
is( $record->field('952')->subfield('b'), $holdingbranch->branchname, 'Record now contains holdingbranch branchname' ); |
110 |
is( $record->field('952')->subfield('b'), $holdingbranch->branchname, 'Record now contains holdingbranch branchname' ); |
|
Lines 119-130
subtest 'ExpandCodedFields tests' => sub {
Link Here
|
| 119 |
|
112 |
|
| 120 |
# reset record for next test |
113 |
# reset record for next test |
| 121 |
$record = $biblio->metadata->record; |
114 |
$record = $biblio->metadata->record; |
| 122 |
is( $record->field('590')->subfield('a'), 'CODE', 'Record reset contains AV Code' ); |
115 |
is( $record->field('590')->subfield('a'), $av->authorised_value, 'Record reset contains AV Code' ); |
| 123 |
|
116 |
|
| 124 |
# set interface |
117 |
# set interface |
| 125 |
$processor->options({ interface => 'intranet' }); |
118 |
$processor->options({ interface => 'intranet' }); |
| 126 |
$result = $processor->process( $record ); |
119 |
$result = $processor->process( $record ); |
| 127 |
is( $record->field('590')->subfield('a'), 'Description should show', 'Original record now contains AV description (interface set to intranet)' ); |
120 |
is( $record->field('590')->subfield('a'), $av->lib, 'Original record now contains AV description (interface set to intranet)' ); |
| 128 |
is( $record->field('942')->subfield('n'), 1, 'Item suppression field remains numeric after filtering' ); |
121 |
is( $record->field('942')->subfield('n'), 1, 'Item suppression field remains numeric after filtering' ); |
| 129 |
|
122 |
|
| 130 |
$schema->storage->txn_rollback(); |
123 |
$schema->storage->txn_rollback(); |
| 131 |
- |
|
|