Lines 32-38
use C4::Context;
Link Here
|
32 |
use Koha::Authority; |
32 |
use Koha::Authority; |
33 |
use Koha::Authorities; |
33 |
use Koha::Authorities; |
34 |
use Koha::Authority::MergeRequest; |
34 |
use Koha::Authority::MergeRequest; |
35 |
use Koha::Authority::MergeRequests; |
|
|
36 |
use Koha::Authority::Type; |
35 |
use Koha::Authority::Type; |
37 |
use Koha::Authority::Types; |
36 |
use Koha::Authority::Types; |
38 |
use Koha::Database; |
37 |
use Koha::Database; |
Lines 91-125
subtest 'New merge request, method oldmarc' => sub {
Link Here
|
91 |
}); |
90 |
}); |
92 |
like( $req->reportxml, qr/b_findme/, 'Reportxml initialized' ); |
91 |
like( $req->reportxml, qr/b_findme/, 'Reportxml initialized' ); |
93 |
|
92 |
|
94 |
# Check if oldmarc is a MARC::Record and has one field |
93 |
# Check if oldmarc is a MARC::Record and has one or two fields |
95 |
is( ref( $req->oldmarc ), 'MARC::Record', 'Check oldmarc method' ); |
94 |
is( ref( $req->oldmarc ), 'MARC::Record', 'Check oldmarc method' ); |
96 |
is( scalar $req->oldmarc->fields, 1, 'Contains one field' ); |
95 |
if( C4::Context->preference('marcflavour') eq 'UNIMARC' ) { |
|
|
96 |
is( scalar $req->oldmarc->fields, 2, 'UNIMARC contains two fields' ); |
97 |
} else { |
98 |
is( scalar $req->oldmarc->fields, 1, 'MARC21 contains one field' ); |
99 |
} |
97 |
}; |
100 |
}; |
98 |
|
101 |
|
99 |
subtest 'Testing reporting_tag_xml in MergeRequests' => sub { |
102 |
subtest 'Testing reporting_tag_xml in MergeRequest' => sub { |
100 |
plan tests => 2; |
103 |
plan tests => 2; |
101 |
|
104 |
|
102 |
my $record = MARC::Record->new; |
105 |
my $record = MARC::Record->new; |
103 |
$record->append_fields( |
106 |
$record->append_fields( |
104 |
MARC::Field->new( '024', '', '', a => 'aaa' ), |
107 |
MARC::Field->new( '024', '', '', a => 'aaa' ), |
105 |
MARC::Field->new( '100', '', '', a => 'Best author' ), |
108 |
MARC::Field->new( '110', '', '', a => 'Best author' ), |
106 |
MARC::Field->new( '234', '', '', a => 'Just a field' ), |
109 |
MARC::Field->new( '234', '', '', a => 'Just a field' ), |
107 |
); |
110 |
); |
108 |
my $xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
111 |
my $xml = Koha::Authority::MergeRequest->reporting_tag_xml({ |
109 |
record => $record, tag => '110', |
112 |
record => $record, tag => '100', |
110 |
}); |
113 |
}); |
111 |
is( $xml, undef, 'Expected no result for wrong tag' ); |
114 |
is( $xml, undef, 'Expected no result for wrong tag' ); |
112 |
$xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
115 |
$xml = Koha::Authority::MergeRequest->reporting_tag_xml({ |
113 |
record => $record, tag => '100', |
116 |
record => $record, tag => '110', |
114 |
}); |
117 |
}); |
115 |
my $newrecord = MARC::Record->new_from_xml( |
118 |
my $newrecord = MARC::Record->new_from_xml( |
116 |
$xml, 'UTF-8', |
119 |
$xml, 'UTF-8', |
117 |
C4::Context->preference('marcflavour') eq 'UNIMARC' ? |
120 |
C4::Context->preference('marcflavour') eq 'UNIMARC' ? |
118 |
'UNIMARCAUTH' : |
121 |
'UNIMARCAUTH' : |
119 |
'MARC21', |
122 |
'MARC21', |
120 |
); # MARC format does not actually matter here |
123 |
); |
121 |
cmp_deeply( $record->field('100')->subfields, |
124 |
cmp_deeply( $record->field('110')->subfields, |
122 |
$newrecord->field('100')->subfields, |
125 |
$newrecord->field('110')->subfields, |
123 |
'Compare reporting tag in both records', |
126 |
'Compare reporting tag in both records', |
124 |
); |
127 |
); |
125 |
}; |
128 |
}; |
126 |
- |
|
|