Lines 24-29
use Test::More tests => 2;
Link Here
|
24 |
use Koha::MarcSubfieldStructure; |
24 |
use Koha::MarcSubfieldStructure; |
25 |
use Koha::MarcSubfieldStructures; |
25 |
use Koha::MarcSubfieldStructures; |
26 |
use Koha::Database; |
26 |
use Koha::Database; |
|
|
27 |
use Koha::Util::Dbrev; |
27 |
|
28 |
|
28 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
29 |
|
30 |
|
Lines 67-77
subtest 'get_kohafield_exceptions / sync_kohafield' => sub {
Link Here
|
67 |
# 100a mapped in Default, unmapped in other |
68 |
# 100a mapped in Default, unmapped in other |
68 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '100', tagsubfield => 'a', kohafield => 'biblio.author' })->store; |
69 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '100', tagsubfield => 'a', kohafield => 'biblio.author' })->store; |
69 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '100', tagsubfield => 'a', kohafield => '' })->store; |
70 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '100', tagsubfield => 'a', kohafield => '' })->store; |
70 |
my $res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
71 |
my $res = Koha::Util::Dbrev->get_kohafield_exceptions; |
71 |
is( @$res, 1, 'Found one exception' ); |
72 |
is( @$res, 1, 'Found one exception' ); |
72 |
is( $res->[0]->[1] . $res->[0]->[2], '100a', '100a was reported' ); |
73 |
is( $res->[0]->[1] . $res->[0]->[2], '100a', '100a was reported' ); |
73 |
Koha::MarcSubfieldStructures->sync_kohafield; |
74 |
Koha::Util::Dbrev->sync_kohafield; |
74 |
$res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
75 |
$res = Koha::Util::Dbrev->get_kohafield_exceptions; |
75 |
is( @$res, 0, 'Found no exceptions after syncing' ); |
76 |
is( @$res, 0, 'Found no exceptions after syncing' ); |
76 |
is( Koha::MarcSubfieldStructures->find($fwc, '100', 'a')->kohafield, |
77 |
is( Koha::MarcSubfieldStructures->find($fwc, '100', 'a')->kohafield, |
77 |
'biblio.author', '100a in added framework adjusted' ); |
78 |
'biblio.author', '100a in added framework adjusted' ); |
Lines 81-92
subtest 'get_kohafield_exceptions / sync_kohafield' => sub {
Link Here
|
81 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '245', tagsubfield => 'a', kohafield => q{} })->store; |
82 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '245', tagsubfield => 'a', kohafield => q{} })->store; |
82 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '245', tagsubfield => 'a', kohafield => 'biblio.title' })->store; |
83 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '245', tagsubfield => 'a', kohafield => 'biblio.title' })->store; |
83 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '300', tagsubfield => 'a', kohafield => 'biblioitems.pages' })->store; |
84 |
Koha::MarcSubfieldStructure->new({ frameworkcode => $fwc, tagfield => '300', tagsubfield => 'a', kohafield => 'biblioitems.pages' })->store; |
84 |
$res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
85 |
$res = Koha::Util::Dbrev->get_kohafield_exceptions; |
85 |
is( @$res, 2, 'Found two exceptions' ); |
86 |
is( @$res, 2, 'Found two exceptions' ); |
86 |
is( $res->[0]->[1] . $res->[0]->[2], '245a', '245a was reported' ); |
87 |
is( $res->[0]->[1] . $res->[0]->[2], '245a', '245a was reported' ); |
87 |
is( $res->[1]->[1] . $res->[1]->[2], '300a', '300a was reported' ); |
88 |
is( $res->[1]->[1] . $res->[1]->[2], '300a', '300a was reported' ); |
88 |
Koha::MarcSubfieldStructures->sync_kohafield; |
89 |
Koha::Util::Dbrev->sync_kohafield; |
89 |
$res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
90 |
$res = Koha::Util::Dbrev->get_kohafield_exceptions; |
90 |
is( @$res, 0, 'Found no exceptions after syncing again' ); |
91 |
is( @$res, 0, 'Found no exceptions after syncing again' ); |
91 |
is( Koha::MarcSubfieldStructures->find($fwc, '245', 'a')->kohafield, |
92 |
is( Koha::MarcSubfieldStructures->find($fwc, '245', 'a')->kohafield, |
92 |
undef, '245a in added framework cleared' ); |
93 |
undef, '245a in added framework cleared' ); |
Lines 96-106
subtest 'get_kohafield_exceptions / sync_kohafield' => sub {
Link Here
|
96 |
# 300a mapped in Default to another field than in other framework |
97 |
# 300a mapped in Default to another field than in other framework |
97 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '300', tagsubfield => 'a', kohafield => 'something_else' })->store; |
98 |
Koha::MarcSubfieldStructure->new({ frameworkcode => q{}, tagfield => '300', tagsubfield => 'a', kohafield => 'something_else' })->store; |
98 |
Koha::MarcSubfieldStructures->find($fwc, '300', 'a')->update({ kohafield => 'biblioitems.pages' }); |
99 |
Koha::MarcSubfieldStructures->find($fwc, '300', 'a')->update({ kohafield => 'biblioitems.pages' }); |
99 |
$res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
100 |
$res = Koha::Util::Dbrev->get_kohafield_exceptions; |
100 |
is( @$res, 1, 'Found one exception' ); |
101 |
is( @$res, 1, 'Found one exception' ); |
101 |
is( $res->[0]->[1] . $res->[0]->[2], '300a', '300a was reported again' ); |
102 |
is( $res->[0]->[1] . $res->[0]->[2], '300a', '300a was reported again' ); |
102 |
Koha::MarcSubfieldStructures->sync_kohafield; |
103 |
Koha::Util::Dbrev->sync_kohafield; |
103 |
$res = Koha::MarcSubfieldStructures->get_kohafield_exceptions; |
104 |
$res = Koha::Util::Dbrev->get_kohafield_exceptions; |
104 |
is( @$res, 0, 'Found no exceptions after third syncing' ); |
105 |
is( @$res, 0, 'Found no exceptions after third syncing' ); |
105 |
is( Koha::MarcSubfieldStructures->find($fwc, '300', 'a')->kohafield, |
106 |
is( Koha::MarcSubfieldStructures->find($fwc, '300', 'a')->kohafield, |
106 |
'something_else', '300a in added framework adjusted' ); |
107 |
'something_else', '300a in added framework adjusted' ); |
107 |
- |
|
|