Lines 19-28
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 5; |
|
|
23 |
use MARC::Field; |
24 |
use MARC::File::XML; |
25 |
use MARC::Record; |
26 |
use Test::Deep; |
23 |
|
27 |
|
24 |
use Koha::Authority; |
28 |
use Koha::Authority; |
25 |
use Koha::Authorities; |
29 |
use Koha::Authorities; |
|
|
30 |
use Koha::Authority::MergeRequest; |
31 |
use Koha::Authority::MergeRequests; |
26 |
use Koha::Authority::Type; |
32 |
use Koha::Authority::Type; |
27 |
use Koha::Authority::Types; |
33 |
use Koha::Authority::Types; |
28 |
use Koha::Database; |
34 |
use Koha::Database; |
Lines 51-55
is( Koha::Authorities->search->count, $nb_of_authorities + 2, 'The 2 au
Link Here
|
51 |
$new_authority_1->delete; |
57 |
$new_authority_1->delete; |
52 |
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the authority' ); |
58 |
is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the authority' ); |
53 |
|
59 |
|
|
|
60 |
subtest 'New merge request, method oldmarc' => sub { |
61 |
plan tests => 4; |
62 |
|
63 |
my $marc = MARC::Record->new; |
64 |
$marc->append_fields( |
65 |
MARC::Field->new( '100', '', '', a => 'a', b => 'b_findme' ), |
66 |
MARC::Field->new( '200', '', '', a => 'aa' ), |
67 |
); |
68 |
my $req = Koha::Authority::MergeRequest->new({ |
69 |
authid => $new_authority_2->authid, |
70 |
reportxml => 'Should be discarded', |
71 |
}); |
72 |
is( $req->reportxml, undef, 'Reportxml is undef without oldrecord' ); |
73 |
|
74 |
$req = Koha::Authority::MergeRequest->new({ |
75 |
authid => $new_authority_2->authid, |
76 |
oldrecord => $marc, |
77 |
}); |
78 |
like( $req->reportxml, qr/b_findme/, 'Reportxml initialized' ); |
79 |
|
80 |
# Check if oldmarc is a MARC::Record and has one field |
81 |
is( ref( $req->oldmarc ), 'MARC::Record', 'Check oldmarc method' ); |
82 |
is( scalar $req->oldmarc->fields, 1, 'Contains one field' ); |
83 |
}; |
84 |
|
85 |
subtest 'Testing reporting_tag_xml in MergeRequests' => sub { |
86 |
plan tests => 2; |
87 |
|
88 |
my $record = MARC::Record->new; |
89 |
$record->append_fields( |
90 |
MARC::Field->new( '024', '', '', a => 'aaa' ), |
91 |
MARC::Field->new( '100', '', '', a => 'Best author' ), |
92 |
MARC::Field->new( '234', '', '', a => 'Just a field' ), |
93 |
); |
94 |
my $xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
95 |
record => $record, tag => '110', |
96 |
}); |
97 |
is( $xml, undef, 'Expected no result for wrong tag' ); |
98 |
$xml = Koha::Authority::MergeRequests->reporting_tag_xml({ |
99 |
record => $record, tag => '100', |
100 |
}); |
101 |
my $newrecord = MARC::Record->new_from_xml( |
102 |
$xml, 'UTF-8', |
103 |
C4::Context->preference('marcflavour') eq 'UNIMARC' ? |
104 |
'UNIMARCAUTH' : |
105 |
'MARC21', |
106 |
); # MARC format does not actually matter here |
107 |
cmp_deeply( $record->field('100')->subfields, |
108 |
$newrecord->field('100')->subfields, |
109 |
'Compare reporting tag in both records', |
110 |
); |
111 |
}; |
112 |
|
54 |
$schema->storage->txn_rollback; |
113 |
$schema->storage->txn_rollback; |
55 |
1; |
|
|
56 |
- |