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

(-)a/t/db_dependent/Biblio/TransformKohaToMarc.t (-4 / +14 lines)
Lines 12-17 use C4::Biblio; Link Here
12
12
13
my $schema  = Koha::Database->new->schema;
13
my $schema  = Koha::Database->new->schema;
14
$schema->storage->txn_begin;
14
$schema->storage->txn_begin;
15
our $builder = t::lib::TestBuilder->new;
15
16
16
# Create/overwrite some Koha to MARC mappings in default framework
17
# Create/overwrite some Koha to MARC mappings in default framework
17
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete;
18
Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' })->delete;
Lines 77-90 subtest "Working with control fields" => sub { Link Here
77
    is( $record->field('001')->data, 'all', 'Verify field 001' );
78
    is( $record->field('001')->data, 'all', 'Verify field 001' );
78
};
79
};
79
80
80
subtest "Add test for no_split option" => sub {
81
subtest "Add tests for _check_split" => sub {
81
    plan tests => 4;
82
    plan tests => 7;
82
83
83
    Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'a' })->delete;
84
    Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'a' })->delete;
84
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'a', kohafield => 'items.fld1' })->store;
85
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'a', kohafield => 'items.fld1' })->store;
85
    Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'b' })->delete;
86
    Koha::MarcSubfieldStructures->search({ frameworkcode => '', tagfield => '952', tagsubfield => 'b' })->delete;
86
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'b', kohafield => 'items.fld1' })->store;
87
    Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '952', tagsubfield => 'b', kohafield => 'items.fld1' })->store;
87
    Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
88
    Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
89
    # add 952a repeatable in another framework
90
    my $fw =  $builder->build({ source => 'BiblioFramework' })->{frameworkcode};
91
    Koha::MarcSubfieldStructure->new({ frameworkcode => $fw, tagfield => '952', tagsubfield => 'a', repeatable => 1 })->store;
88
92
89
    # Test single value in fld1
93
    # Test single value in fld1
90
    my @cols = ( 'items.fld1' => '01' );
94
    my @cols = ( 'items.fld1' => '01' );
Lines 92-102 subtest "Add test for no_split option" => sub { Link Here
92
    is( $record->subfield( '952', 'a' ), '01', 'Check single in 952a' );
96
    is( $record->subfield( '952', 'a' ), '01', 'Check single in 952a' );
93
    is( $record->subfield( '952', 'b' ), '01', 'Check single in 952b' );
97
    is( $record->subfield( '952', 'b' ), '01', 'Check single in 952b' );
94
98
95
    # Test glued (composite) value in fld1
99
    # Test glued (composite) value in fld1 with no_split parameter
96
    @cols = ( 'items.fld1' => '01 | 02' );
100
    @cols = ( 'items.fld1' => '01 | 02' );
97
    $record = C4::Biblio::TransformKohaToMarc( { @cols }, { no_split => 1 } );
101
    $record = C4::Biblio::TransformKohaToMarc( { @cols }, { no_split => 1 } );
98
    is( $record->subfield( '952', 'a' ), '01 | 02', 'Check composite in 952a' );
102
    is( $record->subfield( '952', 'a' ), '01 | 02', 'Check composite in 952a' );
99
    is( $record->subfield( '952', 'b' ), '01 | 02', 'Check composite in 952b' );
103
    is( $record->subfield( '952', 'b' ), '01 | 02', 'Check composite in 952b' );
104
    # Test without no_split (subfield is not repeatable)
105
    $record = C4::Biblio::TransformKohaToMarc( { @cols } );
106
    is( $record->subfield( '952', 'a' ), '01 | 02', 'Check composite in 952a' );
107
    # Test with other framework (repeatable)
108
    $record =  C4::Biblio::TransformKohaToMarc( { @cols }, { framework => $fw } );
109
    is( ($record->subfield( '952', 'a' ))[0], '01', "Framework $fw first 952a" );
110
    is( ($record->subfield( '952', 'a' ))[1], '02', "Framework $fw second 952a" );
100
};
111
};
101
112
102
# Cleanup
113
# Cleanup
103
- 

Return to bug 21800