View | Details | Raw Unified | Return to bug 21800
Collapse All | Expand All

(-)a/t/db_dependent/Biblio/TransformKohaToMarc.t (-5 / +9 lines)
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",
(-)a/t/db_dependent/Biblio/TransformMarcToKoha.t (-2 / +18 lines)
Lines 19-25 Link Here
19
# with Koha; if not, see <http://www.gnu.org/licenses>.
19
# with Koha; if not, see <http://www.gnu.org/licenses>.
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use MARC::Record;
23
use MARC::Record;
24
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 108-113 subtest 'Testing _adjust_pubyear' => sub { Link Here
108
    is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' );
108
    is( C4::Biblio::_adjust_pubyear('198-?'), '1980', '198-?' );
109
};
109
};
110
110
111
subtest 'Test repeatable subfields' => sub {
112
    plan tests => 2;
113
114
    # Make 510x repeatable and 510y not
115
    Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '510' })->delete;
116
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'x', kohafield => 'items.test', repeatable => 1 })->store;
117
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '510', tagsubfield => 'y', kohafield => 'items.norepeat', repeatable => 0 })->store;
118
    Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
119
120
121
    my $marc = MARC::Record->new;
122
    $marc->append_fields( MARC::Field->new( '510', '', '', x => '1', x => '2', y => '3 | 4', y => '5' ) ); # actually, we should only have one $y (BZ 24652)
123
    my $result = C4::Biblio::TransformMarcToKoha( $marc );
124
    is( $result->{test}, '1 | 2', 'Check 510x for two values' );
125
    is( $result->{norepeat}, '3 | 4 | 5', 'Check 510y too' );
126
};
127
111
# Cleanup
128
# Cleanup
112
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
129
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
113
$schema->storage->txn_rollback;
130
$schema->storage->txn_rollback;
114
- 

Return to bug 21800