Lines 3-18
use Test::More tests => 1;
Link Here
|
3 |
use MARC::Record; |
3 |
use MARC::Record; |
4 |
|
4 |
|
5 |
use t::lib::Mocks; |
5 |
use t::lib::Mocks; |
|
|
6 |
use Koha::Database; |
7 |
use Koha::Caches; |
8 |
use Koha::MarcSubfieldStructures; |
6 |
use C4::Biblio; |
9 |
use C4::Biblio; |
7 |
|
10 |
|
8 |
t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); |
11 |
my $schema = Koha::Database->new->schema; |
|
|
12 |
$schema->storage->txn_begin; |
13 |
|
14 |
# Create/overwrite some Koha to MARC mappings in default framework |
15 |
my $mapping1 = Koha::MarcSubfieldStructures->find('','300','a') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'a' }); |
16 |
$mapping1->kohafield( "mytable.nicepages" ); |
17 |
$mapping1->store; |
18 |
my $mapping2 = Koha::MarcSubfieldStructures->find('','300','b') // Koha::MarcSubfieldStructure->new({ frameworkcode => '', tagfield => '300', tagsubfield => 'b' }); |
19 |
$mapping2->kohafield( "mytable2.goodillustrations" ); |
20 |
$mapping2->store; |
21 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
9 |
|
22 |
|
10 |
my $record = C4::Biblio::TransformKohaToMarc({ |
23 |
my $record = C4::Biblio::TransformKohaToMarc({ |
11 |
"biblioitems.illus" => "Other physical details", # 300$b |
24 |
"mytable2.goodillustrations" => "Other physical details", # 300$b |
12 |
"biblioitems.pages" => "Extent", # 300$a |
25 |
"mytable.nicepages" => "Extent", # 300$a |
13 |
"biblioitems.size" => "Dimensions", # 300$c |
|
|
14 |
}); |
26 |
}); |
15 |
|
|
|
16 |
my @subfields = $record->field('300')->subfields(); |
27 |
my @subfields = $record->field('300')->subfields(); |
17 |
is_deeply( \@subfields, [ |
28 |
is_deeply( \@subfields, [ |
18 |
[ |
29 |
[ |
Lines 23-31
is_deeply( \@subfields, [
Link Here
|
23 |
'b', |
34 |
'b', |
24 |
'Other physical details' |
35 |
'Other physical details' |
25 |
], |
36 |
], |
26 |
[ |
|
|
27 |
'c', |
28 |
'Dimensions' |
29 |
] |
30 |
], |
37 |
], |
31 |
'TransformKohaToMarc should returns sorted subfields (regression test for bug 12343)' ); |
38 |
'TransformKohaToMarc should return sorted subfields (regression test for bug 12343)' ); |
|
|
39 |
|
40 |
# Cleanup |
41 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
42 |
$schema->storage->txn_rollback; |
32 |
- |
|
|