|
Lines 17-23
$schema->storage->txn_begin;
Link Here
|
| 17 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete; |
17 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete; |
| 18 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a', kohafield => "mytable.nicepages" })->store; |
18 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a', kohafield => "mytable.nicepages" })->store; |
| 19 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' })->delete; |
19 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' })->delete; |
| 20 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => "mytable2.goodillustrations" })->store; |
20 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b', kohafield => "mytable2.goodillustrations", repeatable => 1 })->store; |
| 21 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
21 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
| 22 |
|
22 |
|
| 23 |
my $record = C4::Biblio::TransformKohaToMarc({ |
23 |
my $record = C4::Biblio::TransformKohaToMarc({ |
|
Lines 40-59
is_deeply( \@subfields, [
Link Here
|
| 40 |
|
40 |
|
| 41 |
# Now test multiple mappings per kohafield too |
41 |
# Now test multiple mappings per kohafield too |
| 42 |
subtest "Multiple Koha to MARC mappings (BZ 10306)" => sub { |
42 |
subtest "Multiple Koha to MARC mappings (BZ 10306)" => sub { |
| 43 |
plan tests => 4; |
43 |
plan tests => 5; |
| 44 |
|
44 |
|
| 45 |
# Add260d mapping so that 300a and 260d both map to mytable.nicepages |
45 |
# Add 260d mapping so that 300a and 260d both map to mytable.nicepages |
| 46 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '260', tagsubfield => 'd' })->delete; |
46 |
# Add 260e to test not-repeatable behavior |
|
|
47 |
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '260' })->delete; |
| 47 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'd', kohafield => "mytable.nicepages" })->store; |
48 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'd', kohafield => "mytable.nicepages" })->store; |
|
|
49 |
Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '260', tagsubfield => 'e', kohafield => "mytable.unrepeatable", repeatable => 0 })->store; |
| 48 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
50 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
| 49 |
|
51 |
|
| 50 |
# Include two values in goodillustrations too: should result in two |
52 |
# Include two values in goodillustrations too: should result in two |
| 51 |
# subfields. |
53 |
# subfields. But unrepeatable should result in one field. |
| 52 |
my $record = C4::Biblio::TransformKohaToMarc({ |
54 |
my $record = C4::Biblio::TransformKohaToMarc({ |
| 53 |
"mytable2.goodillustrations" => "good | better", |
55 |
"mytable2.goodillustrations" => "good | better", |
| 54 |
"mytable.nicepages" => "nice", |
56 |
"mytable.nicepages" => "nice", |
|
|
57 |
"mytable.unrepeatable" => "A | B", |
| 55 |
}); |
58 |
}); |
| 56 |
is( $record->subfield('260','d'), "nice", "Check 260d" ); |
59 |
is( $record->subfield('260','d'), "nice", "Check 260d" ); |
|
|
60 |
is( $record->subfield('260','e'), "A | B", "Check 260e" ); |
| 57 |
is( $record->subfield('300','a'), "nice", "Check 300a" ); |
61 |
is( $record->subfield('300','a'), "nice", "Check 300a" ); |
| 58 |
is( $record->subfield('300','b'), "good", "Check first 300b" ); |
62 |
is( $record->subfield('300','b'), "good", "Check first 300b" ); |
| 59 |
is( ($record->field('300')->subfield('b'))[1], "better", |
63 |
is( ($record->field('300')->subfield('b'))[1], "better", |